diff --git a/bin/bench.ml b/bin/bench.ml index 8cfa971..0fc354e 100644 --- a/bin/bench.ml +++ b/bin/bench.ml @@ -24,7 +24,10 @@ let pitcher ~sw nid mclock n rate cmgr (dispatch : (int, Mtime.t) Hashtbl.t) : let id = i * prime in let cmd = Command. - {op= Write ("asdf", "asdf"); id; trace_start= Unix.gettimeofday ()} + { op= Write ("asdf", "asdf") + ; id + ; submitted= Unix.gettimeofday () + ; trace_start= Unix.gettimeofday () } in let target = Mtime.add_span prev period |> Option.get in if Mtime.is_later target ~than:(MT.now mclock) then diff --git a/fuzz/dune b/fuzz/dune index 91770e8..876315e 100644 --- a/fuzz/dune +++ b/fuzz/dune @@ -1,3 +1,4 @@ (test (name lib_line_prot) - (libraries ocons.core crowbar mtime)) + (libraries ocons.core crowbar mtime) + (preprocess (pps ppx_jane))) diff --git a/fuzz/lib_line_prot.ml b/fuzz/lib_line_prot.ml index 494a7d1..ccbf9bc 100644 --- a/fuzz/lib_line_prot.ml +++ b/fuzz/lib_line_prot.ml @@ -14,8 +14,8 @@ module Gen = struct ; const NoOp ] let command = - map [op; int; float] (fun op id trace_start -> - Ocons_core.Types.Command.{op; id; trace_start} ) + map [op; int; float; float] (fun op id submitted trace_start -> + Ocons_core.Types.Command.{op; id; submitted; trace_start} ) let log_entry = map [command; int] (fun command term -> {command; term}) @@ -39,7 +39,13 @@ let test_client_request r = @@ fun bw -> Line_prot.External_infra.serialise_request r bw ; let r' = Line_prot.External_infra.parse_request br in - check_eq ~cmp:Command.compare ~pp:Command.pp_mach r r' + (* compare *) + check_eq ~cmp:Command.compare ~pp:Command.pp_mach r r'; + (* hash *) + check_eq ~pp:Command.pp_mach r r' ~cmp:(fun a b -> + let ha, hb = Command.hash a, Command.hash b in + Int.compare ha hb + ) let test_client_response r = let open Crowbar in diff --git a/impl/fuzz/test_msgs.ml b/impl/fuzz/test_msgs.ml index e69a4fc..e289eb3 100644 --- a/impl/fuzz/test_msgs.ml +++ b/impl/fuzz/test_msgs.ml @@ -1,7 +1,9 @@ module C = Crowbar let entries_equal (ea, la) (eb, lb) = - la = lb && List.equal ( = ) (Iter.to_list ea) (Iter.to_list eb) + la = lb + && List.equal [%compare.equal: Ocons_core.Types.log_entry] (Iter.to_list ea) + (Iter.to_list eb) module Gen = struct open Ocons_core.Types @@ -17,13 +19,22 @@ module Gen = struct ; const NoOp ] let command = - map [op; int] (fun op id -> - Ocons_core.Types.Command.{op; id; trace_start= -1.} ) + with_printer Command.pp + @@ map [op; int; float; float] (fun op id submitted trace_start -> + Ocons_core.Types.Command.{op; id; trace_start; submitted} ) - let log_entry = map [command; int] (fun command term -> {command; term}) + let log_entry = + with_printer log_entry_pp + @@ map [command; int] (fun command term -> {command; term}) + + let pp_entries ppf (v, _) = + Fmt.pf ppf "%a" + Fmt.(brackets @@ list ~sep:comma log_entry_pp_mach) + (Iter.to_list v) let entries = - map [list log_entry] (fun les -> (Iter.of_list les, List.length les)) + with_printer pp_entries + @@ map [list log_entry] (fun les -> (Iter.of_list les, List.length les)) let conspire_value : Impl_core.ConspireSS.value gen = list command end @@ -43,7 +54,7 @@ let test_entry_equality les = @@ fun bw -> LP.SerPrim.entries w_entries bw ; let r_entries = LP.DeserPrim.entries br in - check_eq ~eq:entries_equal w_entries r_entries + check_eq ~pp:Gen.pp_entries ~eq:entries_equal w_entries r_entries module Paxos = struct open Impl_core.Paxos diff --git a/impl/test/test_conspire_dc.ml b/impl/test/test_conspire_dc.ml index 29fb0a0..45bd24f 100644 --- a/impl/test/test_conspire_dc.ml +++ b/impl/test/test_conspire_dc.ml @@ -89,15 +89,15 @@ let%expect_test "local_commit" = conspire = { rep = { state = - { vval = 34e452ffd92c22ea72ef125a33a0a593; vterm = 0; term = 0; - commit_index = 34e452ffd92c22ea72ef125a33a0a593 }; + { vval = 2a593842bdac635313d582f80fb0a066; vterm = 0; term = 0; + commit_index = 2a593842bdac635313d582f80fb0a066 }; store = { ctree = - [(34e452ffd92c22ea72ef125a33a0a593: + [(2a593842bdac635313d582f80fb0a066: { node = (1, d41d8cd98f00b204e9800998ecf8427e, ([Command(Read c0, 1)], 1.00000)); - parent = ; key = 34e452ffd92c22ea72ef125a33a0a593 }); + parent = ; key = 2a593842bdac635313d582f80fb0a066 }); (d41d8cd98f00b204e9800998ecf8427e: Root)]; root = d41d8cd98f00b204e9800998ecf8427e }; remotes = }; @@ -118,15 +118,15 @@ let%expect_test "local_commit" = conspire = { rep = { state = - { vval = 34e452ffd92c22ea72ef125a33a0a593; vterm = 0; term = 0; - commit_index = 34e452ffd92c22ea72ef125a33a0a593 }; + { vval = 2a593842bdac635313d582f80fb0a066; vterm = 0; term = 0; + commit_index = 2a593842bdac635313d582f80fb0a066 }; store = { ctree = - [(34e452ffd92c22ea72ef125a33a0a593: + [(2a593842bdac635313d582f80fb0a066: { node = (1, d41d8cd98f00b204e9800998ecf8427e, ([Command(Read c0, 1)], 1.00000)); - parent = ; key = 34e452ffd92c22ea72ef125a33a0a593 }); + parent = ; key = 2a593842bdac635313d582f80fb0a066 }); (d41d8cd98f00b204e9800998ecf8427e: Root)]; root = d41d8cd98f00b204e9800998ecf8427e }; remotes = }; @@ -149,20 +149,20 @@ let%expect_test "local_commit" = conspire = { rep = { state = - { vval = ccfc0ddc71cfcede53a100a51835b7ff; vterm = 0; term = 0; - commit_index = ccfc0ddc71cfcede53a100a51835b7ff }; + { vval = 5cd295d17b5aa74c6eccfe593600bc73; vterm = 0; term = 0; + commit_index = 5cd295d17b5aa74c6eccfe593600bc73 }; store = { ctree = - [(34e452ffd92c22ea72ef125a33a0a593: + [(2a593842bdac635313d582f80fb0a066: { node = (1, d41d8cd98f00b204e9800998ecf8427e, ([Command(Read c0, 1)], 1.00000)); - parent = ; key = 34e452ffd92c22ea72ef125a33a0a593 }); - (ccfc0ddc71cfcede53a100a51835b7ff: + parent = ; key = 2a593842bdac635313d582f80fb0a066 }); + (5cd295d17b5aa74c6eccfe593600bc73: { node = - (2, 34e452ffd92c22ea72ef125a33a0a593, + (2, 2a593842bdac635313d582f80fb0a066, ([Command(Read c1, 2); Command(Read c2, 3)], 2.00000)); - parent = ; key = ccfc0ddc71cfcede53a100a51835b7ff }); + parent = ; key = 5cd295d17b5aa74c6eccfe593600bc73 }); (d41d8cd98f00b204e9800998ecf8427e: Root)]; root = d41d8cd98f00b204e9800998ecf8427e }; remotes = }; @@ -264,15 +264,15 @@ let%expect_test "e2e commit" = conspire = { rep = { state = - { vval = c4677fbe3fa92d4246f849e282f15527; vterm = 0; term = 0; + { vval = 4f1688bf7767c0d49f5ce96ed21dfa21; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }; store = { ctree = - [(c4677fbe3fa92d4246f849e282f15527: + [(4f1688bf7767c0d49f5ce96ed21dfa21: { node = (1, d41d8cd98f00b204e9800998ecf8427e, ([Command(Read c1, 1)], 1.00000)); - parent = ; key = c4677fbe3fa92d4246f849e282f15527 }); + parent = ; key = 4f1688bf7767c0d49f5ce96ed21dfa21 }); (d41d8cd98f00b204e9800998ecf8427e: Root)]; root = d41d8cd98f00b204e9800998ecf8427e }; remotes = }; @@ -293,39 +293,39 @@ let%expect_test "e2e commit" = clock = } actions: [Send(1,(Conspire_dc.Types.Conspire { ctree = - (Some { new_head = c4677fbe3fa92d4246f849e282f15527; + (Some { new_head = 4f1688bf7767c0d49f5ce96ed21dfa21; extension = [(1, d41d8cd98f00b204e9800998ecf8427e, ([Command(Read c1, 1)], 1.00000))] }); cons = - (Some { vval = c4677fbe3fa92d4246f849e282f15527; + (Some { vval = 4f1688bf7767c0d49f5ce96ed21dfa21; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }) })) Send(2,(Conspire_dc.Types.Conspire { ctree = - (Some { new_head = c4677fbe3fa92d4246f849e282f15527; + (Some { new_head = 4f1688bf7767c0d49f5ce96ed21dfa21; extension = [(1, d41d8cd98f00b204e9800998ecf8427e, ([Command(Read c1, 1)], 1.00000))] }); cons = - (Some { vval = c4677fbe3fa92d4246f849e282f15527; + (Some { vval = 4f1688bf7767c0d49f5ce96ed21dfa21; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }) })) Send(3,(Conspire_dc.Types.Conspire { ctree = - (Some { new_head = c4677fbe3fa92d4246f849e282f15527; + (Some { new_head = 4f1688bf7767c0d49f5ce96ed21dfa21; extension = [(1, d41d8cd98f00b204e9800998ecf8427e, ([Command(Read c1, 1)], 1.00000))] }); cons = - (Some { vval = c4677fbe3fa92d4246f849e282f15527; + (Some { vval = 4f1688bf7767c0d49f5ce96ed21dfa21; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }) @@ -338,15 +338,15 @@ let%expect_test "e2e commit" = conspire = { rep = { state = - { vval = c4677fbe3fa92d4246f849e282f15527; vterm = 0; term = 0; + { vval = 4f1688bf7767c0d49f5ce96ed21dfa21; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }; store = { ctree = - [(c4677fbe3fa92d4246f849e282f15527: + [(4f1688bf7767c0d49f5ce96ed21dfa21: { node = (1, d41d8cd98f00b204e9800998ecf8427e, ([Command(Read c1, 1)], 1.00000)); - parent = ; key = c4677fbe3fa92d4246f849e282f15527 }); + parent = ; key = 4f1688bf7767c0d49f5ce96ed21dfa21 }); (d41d8cd98f00b204e9800998ecf8427e: Root)]; root = d41d8cd98f00b204e9800998ecf8427e }; remotes = }; @@ -367,45 +367,45 @@ let%expect_test "e2e commit" = clock = } actions: [Send(0,(Conspire_dc.Types.Conspire { ctree = - (Some { new_head = c4677fbe3fa92d4246f849e282f15527; + (Some { new_head = 4f1688bf7767c0d49f5ce96ed21dfa21; extension = [(1, d41d8cd98f00b204e9800998ecf8427e, ([Command(Read c1, 1)], 1.00000))] }); cons = - (Some { vval = c4677fbe3fa92d4246f849e282f15527; + (Some { vval = 4f1688bf7767c0d49f5ce96ed21dfa21; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }) })) Send(2,(Conspire_dc.Types.Conspire { ctree = - (Some { new_head = c4677fbe3fa92d4246f849e282f15527; + (Some { new_head = 4f1688bf7767c0d49f5ce96ed21dfa21; extension = [(1, d41d8cd98f00b204e9800998ecf8427e, ([Command(Read c1, 1)], 1.00000))] }); cons = - (Some { vval = c4677fbe3fa92d4246f849e282f15527; + (Some { vval = 4f1688bf7767c0d49f5ce96ed21dfa21; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }) })) Send(3,(Conspire_dc.Types.Conspire { ctree = - (Some { new_head = c4677fbe3fa92d4246f849e282f15527; + (Some { new_head = 4f1688bf7767c0d49f5ce96ed21dfa21; extension = [(1, d41d8cd98f00b204e9800998ecf8427e, ([Command(Read c1, 1)], 1.00000))] }); cons = - (Some { vval = c4677fbe3fa92d4246f849e282f15527; + (Some { vval = 4f1688bf7767c0d49f5ce96ed21dfa21; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }) }))] |}] ; let root_clk = t0.conspire.rep.store.root in - let c1_clk = Md5.of_hex_exn "c4677fbe3fa92d4246f849e282f15527" in + let c1_clk = DC.Conspire.CTree.make_key root_clk ([c1], 1. |> Utils.float_to_time) in let replication_message = Conspire (Ok @@ -424,21 +424,21 @@ let%expect_test "e2e commit" = conspire = { rep = { state = - { vval = c4677fbe3fa92d4246f849e282f15527; vterm = 0; term = 0; + { vval = 4f1688bf7767c0d49f5ce96ed21dfa21; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }; store = { ctree = - [(c4677fbe3fa92d4246f849e282f15527: + [(4f1688bf7767c0d49f5ce96ed21dfa21: { node = (1, d41d8cd98f00b204e9800998ecf8427e, ([Command(Read c1, 1)], 1.00000)); - parent = ; key = c4677fbe3fa92d4246f849e282f15527 }); + parent = ; key = 4f1688bf7767c0d49f5ce96ed21dfa21 }); (d41d8cd98f00b204e9800998ecf8427e: Root)]; root = d41d8cd98f00b204e9800998ecf8427e }; remotes = }; other_nodes_state = [(1: - { vval = c4677fbe3fa92d4246f849e282f15527; vterm = 0; term = 0; + { vval = 4f1688bf7767c0d49f5ce96ed21dfa21; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }); (2: { vval = d41d8cd98f00b204e9800998ecf8427e; vterm = 0; term = 0; @@ -460,24 +460,24 @@ let%expect_test "e2e commit" = conspire = { rep = { state = - { vval = c4677fbe3fa92d4246f849e282f15527; vterm = 0; term = 0; - commit_index = c4677fbe3fa92d4246f849e282f15527 }; + { vval = 4f1688bf7767c0d49f5ce96ed21dfa21; vterm = 0; term = 0; + commit_index = 4f1688bf7767c0d49f5ce96ed21dfa21 }; store = { ctree = - [(c4677fbe3fa92d4246f849e282f15527: + [(4f1688bf7767c0d49f5ce96ed21dfa21: { node = (1, d41d8cd98f00b204e9800998ecf8427e, ([Command(Read c1, 1)], 1.00000)); - parent = ; key = c4677fbe3fa92d4246f849e282f15527 }); + parent = ; key = 4f1688bf7767c0d49f5ce96ed21dfa21 }); (d41d8cd98f00b204e9800998ecf8427e: Root)]; root = d41d8cd98f00b204e9800998ecf8427e }; remotes = }; other_nodes_state = [(1: - { vval = c4677fbe3fa92d4246f849e282f15527; vterm = 0; term = 0; + { vval = 4f1688bf7767c0d49f5ce96ed21dfa21; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }); (2: - { vval = c4677fbe3fa92d4246f849e282f15527; vterm = 0; term = 0; + { vval = 4f1688bf7767c0d49f5ce96ed21dfa21; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }); (3: { vval = d41d8cd98f00b204e9800998ecf8427e; vterm = 0; term = 0; @@ -491,25 +491,25 @@ let%expect_test "e2e commit" = Send(1,(Conspire_dc.Types.Conspire { ctree = None; cons = - (Some { vval = c4677fbe3fa92d4246f849e282f15527; + (Some { vval = 4f1688bf7767c0d49f5ce96ed21dfa21; vterm = 0; term = 0; - commit_index = c4677fbe3fa92d4246f849e282f15527 + commit_index = 4f1688bf7767c0d49f5ce96ed21dfa21 }) })) Send(2,(Conspire_dc.Types.Conspire { ctree = None; cons = - (Some { vval = c4677fbe3fa92d4246f849e282f15527; + (Some { vval = 4f1688bf7767c0d49f5ce96ed21dfa21; vterm = 0; term = 0; - commit_index = c4677fbe3fa92d4246f849e282f15527 + commit_index = 4f1688bf7767c0d49f5ce96ed21dfa21 }) })) Send(3,(Conspire_dc.Types.Conspire { ctree = None; cons = - (Some { vval = c4677fbe3fa92d4246f849e282f15527; + (Some { vval = 4f1688bf7767c0d49f5ce96ed21dfa21; vterm = 0; term = 0; - commit_index = c4677fbe3fa92d4246f849e282f15527 + commit_index = 4f1688bf7767c0d49f5ce96ed21dfa21 }) }))] |}] @@ -632,15 +632,15 @@ let%expect_test "batching" = conspire = { rep = { state = - { vval = 34e452ffd92c22ea72ef125a33a0a593; vterm = 0; term = 0; + { vval = 2a593842bdac635313d582f80fb0a066; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }; store = { ctree = - [(34e452ffd92c22ea72ef125a33a0a593: + [(2a593842bdac635313d582f80fb0a066: { node = (1, d41d8cd98f00b204e9800998ecf8427e, ([Command(Read c0, 1)], 1.00000)); - parent = ; key = 34e452ffd92c22ea72ef125a33a0a593 }); + parent = ; key = 2a593842bdac635313d582f80fb0a066 }); (d41d8cd98f00b204e9800998ecf8427e: Root)]; root = d41d8cd98f00b204e9800998ecf8427e }; remotes = }; @@ -663,39 +663,39 @@ let%expect_test "batching" = clock = } actions: [Send(1,(Conspire_dc.Types.Conspire { ctree = - (Some { new_head = 34e452ffd92c22ea72ef125a33a0a593; + (Some { new_head = 2a593842bdac635313d582f80fb0a066; extension = [(1, d41d8cd98f00b204e9800998ecf8427e, ([Command(Read c0, 1)], 1.00000))] }); cons = - (Some { vval = 34e452ffd92c22ea72ef125a33a0a593; + (Some { vval = 2a593842bdac635313d582f80fb0a066; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }) })) Send(2,(Conspire_dc.Types.Conspire { ctree = - (Some { new_head = 34e452ffd92c22ea72ef125a33a0a593; + (Some { new_head = 2a593842bdac635313d582f80fb0a066; extension = [(1, d41d8cd98f00b204e9800998ecf8427e, ([Command(Read c0, 1)], 1.00000))] }); cons = - (Some { vval = 34e452ffd92c22ea72ef125a33a0a593; + (Some { vval = 2a593842bdac635313d582f80fb0a066; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }) })) Send(3,(Conspire_dc.Types.Conspire { ctree = - (Some { new_head = 34e452ffd92c22ea72ef125a33a0a593; + (Some { new_head = 2a593842bdac635313d582f80fb0a066; extension = [(1, d41d8cd98f00b204e9800998ecf8427e, ([Command(Read c0, 1)], 1.00000))] }); cons = - (Some { vval = 34e452ffd92c22ea72ef125a33a0a593; + (Some { vval = 2a593842bdac635313d582f80fb0a066; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }) @@ -712,20 +712,20 @@ let%expect_test "batching" = conspire = { rep = { state = - { vval = 4208465ea72aa1217306cdb4da303438; vterm = 0; term = 0; + { vval = b906b94dbc8b5fa592ad20c239ec09d6; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }; store = { ctree = - [(34e452ffd92c22ea72ef125a33a0a593: + [(2a593842bdac635313d582f80fb0a066: { node = (1, d41d8cd98f00b204e9800998ecf8427e, ([Command(Read c0, 1)], 1.00000)); - parent = ; key = 34e452ffd92c22ea72ef125a33a0a593 }); - (4208465ea72aa1217306cdb4da303438: + parent = ; key = 2a593842bdac635313d582f80fb0a066 }); + (b906b94dbc8b5fa592ad20c239ec09d6: { node = - (2, 34e452ffd92c22ea72ef125a33a0a593, + (2, 2a593842bdac635313d582f80fb0a066, ([Command(Read c1, 2); Command(Read c2, 3)], 3.00000)); - parent = ; key = 4208465ea72aa1217306cdb4da303438 }); + parent = ; key = b906b94dbc8b5fa592ad20c239ec09d6 }); (d41d8cd98f00b204e9800998ecf8427e: Root)]; root = d41d8cd98f00b204e9800998ecf8427e }; remotes = }; @@ -746,45 +746,45 @@ let%expect_test "batching" = clock = } actions: [Send(1,(Conspire_dc.Types.Conspire { ctree = - (Some { new_head = 4208465ea72aa1217306cdb4da303438; + (Some { new_head = b906b94dbc8b5fa592ad20c239ec09d6; extension = - [(2, 34e452ffd92c22ea72ef125a33a0a593, + [(2, 2a593842bdac635313d582f80fb0a066, ([Command(Read c1, 2); Command(Read c2, 3)], 3.00000)) ] }); cons = - (Some { vval = 4208465ea72aa1217306cdb4da303438; + (Some { vval = b906b94dbc8b5fa592ad20c239ec09d6; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }) })) Send(2,(Conspire_dc.Types.Conspire { ctree = - (Some { new_head = 4208465ea72aa1217306cdb4da303438; + (Some { new_head = b906b94dbc8b5fa592ad20c239ec09d6; extension = - [(2, 34e452ffd92c22ea72ef125a33a0a593, + [(2, 2a593842bdac635313d582f80fb0a066, ([Command(Read c1, 2); Command(Read c2, 3)], 3.00000)) ] }); cons = - (Some { vval = 4208465ea72aa1217306cdb4da303438; + (Some { vval = b906b94dbc8b5fa592ad20c239ec09d6; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }) })) Send(3,(Conspire_dc.Types.Conspire { ctree = - (Some { new_head = 4208465ea72aa1217306cdb4da303438; + (Some { new_head = b906b94dbc8b5fa592ad20c239ec09d6; extension = - [(2, 34e452ffd92c22ea72ef125a33a0a593, + [(2, 2a593842bdac635313d582f80fb0a066, ([Command(Read c1, 2); Command(Read c2, 3)], 3.00000)) ] }); cons = - (Some { vval = 4208465ea72aa1217306cdb4da303438; + (Some { vval = b906b94dbc8b5fa592ad20c239ec09d6; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }) @@ -810,15 +810,15 @@ let%expect_test "Conflict" = conspire = { rep = { state = - { vval = 34e452ffd92c22ea72ef125a33a0a593; vterm = 0; term = 0; + { vval = 2a593842bdac635313d582f80fb0a066; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }; store = { ctree = - [(34e452ffd92c22ea72ef125a33a0a593: + [(2a593842bdac635313d582f80fb0a066: { node = (1, d41d8cd98f00b204e9800998ecf8427e, ([Command(Read c0, 1)], 1.00000)); - parent = ; key = 34e452ffd92c22ea72ef125a33a0a593 }); + parent = ; key = 2a593842bdac635313d582f80fb0a066 }); (d41d8cd98f00b204e9800998ecf8427e: Root)]; root = d41d8cd98f00b204e9800998ecf8427e }; remotes = }; @@ -839,39 +839,39 @@ let%expect_test "Conflict" = clock = } actions: [Send(1,(Conspire_dc.Types.Conspire { ctree = - (Some { new_head = 34e452ffd92c22ea72ef125a33a0a593; + (Some { new_head = 2a593842bdac635313d582f80fb0a066; extension = [(1, d41d8cd98f00b204e9800998ecf8427e, ([Command(Read c0, 1)], 1.00000))] }); cons = - (Some { vval = 34e452ffd92c22ea72ef125a33a0a593; + (Some { vval = 2a593842bdac635313d582f80fb0a066; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }) })) Send(2,(Conspire_dc.Types.Conspire { ctree = - (Some { new_head = 34e452ffd92c22ea72ef125a33a0a593; + (Some { new_head = 2a593842bdac635313d582f80fb0a066; extension = [(1, d41d8cd98f00b204e9800998ecf8427e, ([Command(Read c0, 1)], 1.00000))] }); cons = - (Some { vval = 34e452ffd92c22ea72ef125a33a0a593; + (Some { vval = 2a593842bdac635313d582f80fb0a066; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }) })) Send(3,(Conspire_dc.Types.Conspire { ctree = - (Some { new_head = 34e452ffd92c22ea72ef125a33a0a593; + (Some { new_head = 2a593842bdac635313d582f80fb0a066; extension = [(1, d41d8cd98f00b204e9800998ecf8427e, ([Command(Read c0, 1)], 1.00000))] }); cons = - (Some { vval = 34e452ffd92c22ea72ef125a33a0a593; + (Some { vval = 2a593842bdac635313d582f80fb0a066; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }) @@ -889,15 +889,15 @@ let%expect_test "Conflict" = conspire = { rep = { state = - { vval = 9ddc31c480e04b8965ff34f30c37d919; vterm = 0; term = 0; + { vval = a27fc154024e8c9bb0ba98b71ddadd3a; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }; store = { ctree = - [(9ddc31c480e04b8965ff34f30c37d919: + [(a27fc154024e8c9bb0ba98b71ddadd3a: { node = (1, d41d8cd98f00b204e9800998ecf8427e, ([Command(Read c1, 2)], 1.00000)); - parent = ; key = 9ddc31c480e04b8965ff34f30c37d919 }); + parent = ; key = a27fc154024e8c9bb0ba98b71ddadd3a }); (d41d8cd98f00b204e9800998ecf8427e: Root)]; root = d41d8cd98f00b204e9800998ecf8427e }; remotes = }; @@ -918,45 +918,45 @@ let%expect_test "Conflict" = clock = } actions: [Send(0,(Conspire_dc.Types.Conspire { ctree = - (Some { new_head = 9ddc31c480e04b8965ff34f30c37d919; + (Some { new_head = a27fc154024e8c9bb0ba98b71ddadd3a; extension = [(1, d41d8cd98f00b204e9800998ecf8427e, ([Command(Read c1, 2)], 1.00000))] }); cons = - (Some { vval = 9ddc31c480e04b8965ff34f30c37d919; + (Some { vval = a27fc154024e8c9bb0ba98b71ddadd3a; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }) })) Send(2,(Conspire_dc.Types.Conspire { ctree = - (Some { new_head = 9ddc31c480e04b8965ff34f30c37d919; + (Some { new_head = a27fc154024e8c9bb0ba98b71ddadd3a; extension = [(1, d41d8cd98f00b204e9800998ecf8427e, ([Command(Read c1, 2)], 1.00000))] }); cons = - (Some { vval = 9ddc31c480e04b8965ff34f30c37d919; + (Some { vval = a27fc154024e8c9bb0ba98b71ddadd3a; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }) })) Send(3,(Conspire_dc.Types.Conspire { ctree = - (Some { new_head = 9ddc31c480e04b8965ff34f30c37d919; + (Some { new_head = a27fc154024e8c9bb0ba98b71ddadd3a; extension = [(1, d41d8cd98f00b204e9800998ecf8427e, ([Command(Read c1, 2)], 1.00000))] }); cons = - (Some { vval = 9ddc31c480e04b8965ff34f30c37d919; + (Some { vval = a27fc154024e8c9bb0ba98b71ddadd3a; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }) }))] |}] ; let root_clk = t0.conspire.rep.store.root in - let c0_clk = Md5.of_hex_exn "34e452ffd92c22ea72ef125a33a0a593" in + let c0_clk = DC.Conspire.CTree.make_key root_clk ([c0], 1. |> Utils.float_to_time) in let update_t0 term = Conspire (Ok @@ -975,15 +975,15 @@ let%expect_test "Conflict" = conspire = { rep = { state = - { vval = 34e452ffd92c22ea72ef125a33a0a593; vterm = 0; term = 0; + { vval = 2a593842bdac635313d582f80fb0a066; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }; store = { ctree = - [(34e452ffd92c22ea72ef125a33a0a593: + [(2a593842bdac635313d582f80fb0a066: { node = (1, d41d8cd98f00b204e9800998ecf8427e, ([Command(Read c0, 1)], 1.00000)); - parent = ; key = 34e452ffd92c22ea72ef125a33a0a593 }); + parent = ; key = 2a593842bdac635313d582f80fb0a066 }); (d41d8cd98f00b204e9800998ecf8427e: Root)]; root = d41d8cd98f00b204e9800998ecf8427e }; remotes = }; @@ -992,7 +992,7 @@ let%expect_test "Conflict" = { vval = d41d8cd98f00b204e9800998ecf8427e; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }); (2: - { vval = 34e452ffd92c22ea72ef125a33a0a593; vterm = 0; term = 0; + { vval = 2a593842bdac635313d582f80fb0a066; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }); (3: { vval = d41d8cd98f00b204e9800998ecf8427e; vterm = 0; term = 0; @@ -1003,7 +1003,7 @@ let%expect_test "Conflict" = tick_count = { Conspire_dc.Counter.count = 1; limit = 100 }; clock = } actions: [] |}] ; - let c1_clk = Md5.of_hex_exn "620122743bc84de6b418bd632ea0cdc2" in + let c1_clk = DC.Conspire.CTree.make_key root_clk ([c1], 1. |> Utils.float_to_time) in let update_t1 term = Conspire (Ok @@ -1022,29 +1022,29 @@ let%expect_test "Conflict" = conspire = { rep = { state = - { vval = 34e452ffd92c22ea72ef125a33a0a593; vterm = 0; term = 1; + { vval = 2a593842bdac635313d582f80fb0a066; vterm = 0; term = 1; commit_index = d41d8cd98f00b204e9800998ecf8427e }; store = { ctree = - [(34e452ffd92c22ea72ef125a33a0a593: + [(2a593842bdac635313d582f80fb0a066: { node = (1, d41d8cd98f00b204e9800998ecf8427e, ([Command(Read c0, 1)], 1.00000)); - parent = ; key = 34e452ffd92c22ea72ef125a33a0a593 }); - (620122743bc84de6b418bd632ea0cdc2: + parent = ; key = 2a593842bdac635313d582f80fb0a066 }); + (a27fc154024e8c9bb0ba98b71ddadd3a: { node = (1, d41d8cd98f00b204e9800998ecf8427e, ([Command(Read c1, 2)], 1.00000)); - parent = ; key = 620122743bc84de6b418bd632ea0cdc2 }); + parent = ; key = a27fc154024e8c9bb0ba98b71ddadd3a }); (d41d8cd98f00b204e9800998ecf8427e: Root)]; root = d41d8cd98f00b204e9800998ecf8427e }; remotes = }; other_nodes_state = [(1: - { vval = 620122743bc84de6b418bd632ea0cdc2; vterm = 0; term = 0; + { vval = a27fc154024e8c9bb0ba98b71ddadd3a; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }); (2: - { vval = 34e452ffd92c22ea72ef125a33a0a593; vterm = 0; term = 0; + { vval = 2a593842bdac635313d582f80fb0a066; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }); (3: { vval = d41d8cd98f00b204e9800998ecf8427e; vterm = 0; term = 0; @@ -1057,7 +1057,7 @@ let%expect_test "Conflict" = actions: [Send(1,(Conspire_dc.Types.Conspire { ctree = None; cons = - (Some { vval = 34e452ffd92c22ea72ef125a33a0a593; + (Some { vval = 2a593842bdac635313d582f80fb0a066; vterm = 0; term = 1; commit_index = d41d8cd98f00b204e9800998ecf8427e }) @@ -1065,7 +1065,7 @@ let%expect_test "Conflict" = Send(2,(Conspire_dc.Types.Conspire { ctree = None; cons = - (Some { vval = 34e452ffd92c22ea72ef125a33a0a593; + (Some { vval = 2a593842bdac635313d582f80fb0a066; vterm = 0; term = 1; commit_index = d41d8cd98f00b204e9800998ecf8427e }) @@ -1073,7 +1073,7 @@ let%expect_test "Conflict" = Send(3,(Conspire_dc.Types.Conspire { ctree = None; cons = - (Some { vval = 34e452ffd92c22ea72ef125a33a0a593; + (Some { vval = 2a593842bdac635313d582f80fb0a066; vterm = 0; term = 1; commit_index = d41d8cd98f00b204e9800998ecf8427e }) @@ -1086,29 +1086,29 @@ let%expect_test "Conflict" = conspire = { rep = { state = - { vval = 34e452ffd92c22ea72ef125a33a0a593; vterm = 0; term = 1; + { vval = 2a593842bdac635313d582f80fb0a066; vterm = 0; term = 1; commit_index = d41d8cd98f00b204e9800998ecf8427e }; store = { ctree = - [(34e452ffd92c22ea72ef125a33a0a593: + [(2a593842bdac635313d582f80fb0a066: { node = (1, d41d8cd98f00b204e9800998ecf8427e, ([Command(Read c0, 1)], 1.00000)); - parent = ; key = 34e452ffd92c22ea72ef125a33a0a593 }); - (620122743bc84de6b418bd632ea0cdc2: + parent = ; key = 2a593842bdac635313d582f80fb0a066 }); + (a27fc154024e8c9bb0ba98b71ddadd3a: { node = (1, d41d8cd98f00b204e9800998ecf8427e, ([Command(Read c1, 2)], 1.00000)); - parent = ; key = 620122743bc84de6b418bd632ea0cdc2 }); + parent = ; key = a27fc154024e8c9bb0ba98b71ddadd3a }); (d41d8cd98f00b204e9800998ecf8427e: Root)]; root = d41d8cd98f00b204e9800998ecf8427e }; remotes = }; other_nodes_state = [(1: - { vval = 620122743bc84de6b418bd632ea0cdc2; vterm = 0; term = 1; + { vval = a27fc154024e8c9bb0ba98b71ddadd3a; vterm = 0; term = 1; commit_index = d41d8cd98f00b204e9800998ecf8427e }); (2: - { vval = 34e452ffd92c22ea72ef125a33a0a593; vterm = 0; term = 0; + { vval = 2a593842bdac635313d582f80fb0a066; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }); (3: { vval = d41d8cd98f00b204e9800998ecf8427e; vterm = 0; term = 0; @@ -1127,29 +1127,29 @@ let%expect_test "Conflict" = conspire = { rep = { state = - { vval = 34e452ffd92c22ea72ef125a33a0a593; vterm = 1; term = 1; + { vval = 2a593842bdac635313d582f80fb0a066; vterm = 1; term = 1; commit_index = d41d8cd98f00b204e9800998ecf8427e }; store = { ctree = - [(34e452ffd92c22ea72ef125a33a0a593: + [(2a593842bdac635313d582f80fb0a066: { node = (1, d41d8cd98f00b204e9800998ecf8427e, ([Command(Read c0, 1)], 1.00000)); - parent = ; key = 34e452ffd92c22ea72ef125a33a0a593 }); - (620122743bc84de6b418bd632ea0cdc2: + parent = ; key = 2a593842bdac635313d582f80fb0a066 }); + (a27fc154024e8c9bb0ba98b71ddadd3a: { node = (1, d41d8cd98f00b204e9800998ecf8427e, ([Command(Read c1, 2)], 1.00000)); - parent = ; key = 620122743bc84de6b418bd632ea0cdc2 }); + parent = ; key = a27fc154024e8c9bb0ba98b71ddadd3a }); (d41d8cd98f00b204e9800998ecf8427e: Root)]; root = d41d8cd98f00b204e9800998ecf8427e }; remotes = }; other_nodes_state = [(1: - { vval = 620122743bc84de6b418bd632ea0cdc2; vterm = 0; term = 1; + { vval = a27fc154024e8c9bb0ba98b71ddadd3a; vterm = 0; term = 1; commit_index = d41d8cd98f00b204e9800998ecf8427e }); (2: - { vval = 34e452ffd92c22ea72ef125a33a0a593; vterm = 0; term = 1; + { vval = 2a593842bdac635313d582f80fb0a066; vterm = 0; term = 1; commit_index = d41d8cd98f00b204e9800998ecf8427e }); (3: { vval = d41d8cd98f00b204e9800998ecf8427e; vterm = 0; term = 0; @@ -1162,7 +1162,7 @@ let%expect_test "Conflict" = actions: [Send(1,(Conspire_dc.Types.Conspire { ctree = None; cons = - (Some { vval = 34e452ffd92c22ea72ef125a33a0a593; + (Some { vval = 2a593842bdac635313d582f80fb0a066; vterm = 1; term = 1; commit_index = d41d8cd98f00b204e9800998ecf8427e }) @@ -1170,7 +1170,7 @@ let%expect_test "Conflict" = Send(2,(Conspire_dc.Types.Conspire { ctree = None; cons = - (Some { vval = 34e452ffd92c22ea72ef125a33a0a593; + (Some { vval = 2a593842bdac635313d582f80fb0a066; vterm = 1; term = 1; commit_index = d41d8cd98f00b204e9800998ecf8427e }) @@ -1178,7 +1178,7 @@ let%expect_test "Conflict" = Send(3,(Conspire_dc.Types.Conspire { ctree = None; cons = - (Some { vval = 34e452ffd92c22ea72ef125a33a0a593; + (Some { vval = 2a593842bdac635313d582f80fb0a066; vterm = 1; term = 1; commit_index = d41d8cd98f00b204e9800998ecf8427e }) diff --git a/impl/test/test_conspire_leader.ml b/impl/test/test_conspire_leader.ml index 68e290e..cf63df5 100644 --- a/impl/test/test_conspire_leader.ml +++ b/impl/test/test_conspire_leader.ml @@ -47,14 +47,14 @@ let%expect_test "local_commit" = conspire = { rep = { state = - { vval = 1183a904cd1a3b8f3cf219be9367701f; vterm = 0; term = 0; - commit_index = 1183a904cd1a3b8f3cf219be9367701f }; + { vval = 977400b12d4c3868588f1db7a6f272da; vterm = 0; term = 0; + commit_index = 977400b12d4c3868588f1db7a6f272da }; store = { ctree = - [(1183a904cd1a3b8f3cf219be9367701f: + [(977400b12d4c3868588f1db7a6f272da: { node = (1, d41d8cd98f00b204e9800998ecf8427e, [Command(Read c1, 1)]); - parent = ; key = 1183a904cd1a3b8f3cf219be9367701f }); + parent = ; key = 977400b12d4c3868588f1db7a6f272da }); (d41d8cd98f00b204e9800998ecf8427e: Root)]; root = d41d8cd98f00b204e9800998ecf8427e }; remotes = }; @@ -72,19 +72,19 @@ let%expect_test "local_commit" = conspire = { rep = { state = - { vval = 7f2c0aae94bf199f9b303480537af547; vterm = 0; term = 0; - commit_index = 7f2c0aae94bf199f9b303480537af547 }; + { vval = d1c958ddddd59d3d3a315b1bf5ab1e39; vterm = 0; term = 0; + commit_index = d1c958ddddd59d3d3a315b1bf5ab1e39 }; store = { ctree = - [(1183a904cd1a3b8f3cf219be9367701f: + [(977400b12d4c3868588f1db7a6f272da: { node = (1, d41d8cd98f00b204e9800998ecf8427e, [Command(Read c1, 1)]); - parent = ; key = 1183a904cd1a3b8f3cf219be9367701f }); - (7f2c0aae94bf199f9b303480537af547: + parent = ; key = 977400b12d4c3868588f1db7a6f272da }); + (d1c958ddddd59d3d3a315b1bf5ab1e39: { node = - (2, 1183a904cd1a3b8f3cf219be9367701f, + (2, 977400b12d4c3868588f1db7a6f272da, [Command(Read c2, 3); Command(Read c3, 2)]); - parent = ; key = 7f2c0aae94bf199f9b303480537af547 }); + parent = ; key = d1c958ddddd59d3d3a315b1bf5ab1e39 }); (d41d8cd98f00b204e9800998ecf8427e: Root)]; root = d41d8cd98f00b204e9800998ecf8427e }; remotes = }; @@ -110,14 +110,14 @@ let%expect_test "e2e commit" = conspire = { rep = { state = - { vval = 1183a904cd1a3b8f3cf219be9367701f; vterm = 0; term = 0; + { vval = 977400b12d4c3868588f1db7a6f272da; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }; store = { ctree = - [(1183a904cd1a3b8f3cf219be9367701f: + [(977400b12d4c3868588f1db7a6f272da: { node = (1, d41d8cd98f00b204e9800998ecf8427e, [Command(Read c1, 1)]); - parent = ; key = 1183a904cd1a3b8f3cf219be9367701f }); + parent = ; key = 977400b12d4c3868588f1db7a6f272da }); (d41d8cd98f00b204e9800998ecf8427e: Root)]; root = d41d8cd98f00b204e9800998ecf8427e }; remotes = }; @@ -137,39 +137,39 @@ let%expect_test "e2e commit" = timeout = 2 } } actions: [Send(1,{ ctree = - (Some { new_head = 1183a904cd1a3b8f3cf219be9367701f; + (Some { new_head = 977400b12d4c3868588f1db7a6f272da; extension = [(1, d41d8cd98f00b204e9800998ecf8427e, [Command(Read c1, 1)])] }); cons = - (Some { vval = 1183a904cd1a3b8f3cf219be9367701f; + (Some { vval = 977400b12d4c3868588f1db7a6f272da; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }) }) Send(2,{ ctree = - (Some { new_head = 1183a904cd1a3b8f3cf219be9367701f; + (Some { new_head = 977400b12d4c3868588f1db7a6f272da; extension = [(1, d41d8cd98f00b204e9800998ecf8427e, [Command(Read c1, 1)])] }); cons = - (Some { vval = 1183a904cd1a3b8f3cf219be9367701f; + (Some { vval = 977400b12d4c3868588f1db7a6f272da; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }) }) Send(3,{ ctree = - (Some { new_head = 1183a904cd1a3b8f3cf219be9367701f; + (Some { new_head = 977400b12d4c3868588f1db7a6f272da; extension = [(1, d41d8cd98f00b204e9800998ecf8427e, [Command(Read c1, 1)])] }); cons = - (Some { vval = 1183a904cd1a3b8f3cf219be9367701f; + (Some { vval = 977400b12d4c3868588f1db7a6f272da; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }) })] |}] ; - let hd1 = Md5.of_hex_exn "1183a904cd1a3b8f3cf219be9367701f" in + let hd1 = MP.Conspire.CTree.make_key root_hd [c1] in let update = MP.Conspire.Rep. {ctree= Some {new_head= hd1; extension= [(1, root_hd, [c1])]}; cons= None} @@ -186,10 +186,10 @@ let%expect_test "e2e commit" = commit_index = d41d8cd98f00b204e9800998ecf8427e }; store = { ctree = - [(1183a904cd1a3b8f3cf219be9367701f: + [(977400b12d4c3868588f1db7a6f272da: { node = (1, d41d8cd98f00b204e9800998ecf8427e, [Command(Read c1, 1)]); - parent = ; key = 1183a904cd1a3b8f3cf219be9367701f }); + parent = ; key = 977400b12d4c3868588f1db7a6f272da }); (d41d8cd98f00b204e9800998ecf8427e: Root)]; root = d41d8cd98f00b204e9800998ecf8427e }; remotes = }; @@ -222,20 +222,20 @@ let%expect_test "e2e commit" = conspire = { rep = { state = - { vval = 1183a904cd1a3b8f3cf219be9367701f; vterm = 0; term = 0; + { vval = 977400b12d4c3868588f1db7a6f272da; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }; store = { ctree = - [(1183a904cd1a3b8f3cf219be9367701f: + [(977400b12d4c3868588f1db7a6f272da: { node = (1, d41d8cd98f00b204e9800998ecf8427e, [Command(Read c1, 1)]); - parent = ; key = 1183a904cd1a3b8f3cf219be9367701f }); + parent = ; key = 977400b12d4c3868588f1db7a6f272da }); (d41d8cd98f00b204e9800998ecf8427e: Root)]; root = d41d8cd98f00b204e9800998ecf8427e }; remotes = }; other_nodes_state = [(0: - { vval = 1183a904cd1a3b8f3cf219be9367701f; vterm = 0; term = 0; + { vval = 977400b12d4c3868588f1db7a6f272da; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }); (2: { vval = d41d8cd98f00b204e9800998ecf8427e; vterm = 0; term = 0; @@ -250,7 +250,7 @@ let%expect_test "e2e commit" = } actions: [Send(0,{ ctree = None; cons = - (Some { vval = 1183a904cd1a3b8f3cf219be9367701f; + (Some { vval = 977400b12d4c3868588f1db7a6f272da; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }) })] |}] ; @@ -262,20 +262,20 @@ let%expect_test "e2e commit" = conspire = { rep = { state = - { vval = 1183a904cd1a3b8f3cf219be9367701f; vterm = 0; term = 0; + { vval = 977400b12d4c3868588f1db7a6f272da; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }; store = { ctree = - [(1183a904cd1a3b8f3cf219be9367701f: + [(977400b12d4c3868588f1db7a6f272da: { node = (1, d41d8cd98f00b204e9800998ecf8427e, [Command(Read c1, 1)]); - parent = ; key = 1183a904cd1a3b8f3cf219be9367701f }); + parent = ; key = 977400b12d4c3868588f1db7a6f272da }); (d41d8cd98f00b204e9800998ecf8427e: Root)]; root = d41d8cd98f00b204e9800998ecf8427e }; remotes = }; other_nodes_state = [(1: - { vval = 1183a904cd1a3b8f3cf219be9367701f; vterm = 0; term = 0; + { vval = 977400b12d4c3868588f1db7a6f272da; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }); (2: { vval = d41d8cd98f00b204e9800998ecf8427e; vterm = 0; term = 0; @@ -297,23 +297,23 @@ let%expect_test "e2e commit" = conspire = { rep = { state = - { vval = 1183a904cd1a3b8f3cf219be9367701f; vterm = 0; term = 0; - commit_index = 1183a904cd1a3b8f3cf219be9367701f }; + { vval = 977400b12d4c3868588f1db7a6f272da; vterm = 0; term = 0; + commit_index = 977400b12d4c3868588f1db7a6f272da }; store = { ctree = - [(1183a904cd1a3b8f3cf219be9367701f: + [(977400b12d4c3868588f1db7a6f272da: { node = (1, d41d8cd98f00b204e9800998ecf8427e, [Command(Read c1, 1)]); - parent = ; key = 1183a904cd1a3b8f3cf219be9367701f }); + parent = ; key = 977400b12d4c3868588f1db7a6f272da }); (d41d8cd98f00b204e9800998ecf8427e: Root)]; root = d41d8cd98f00b204e9800998ecf8427e }; remotes = }; other_nodes_state = [(1: - { vval = 1183a904cd1a3b8f3cf219be9367701f; vterm = 0; term = 0; + { vval = 977400b12d4c3868588f1db7a6f272da; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }); (2: - { vval = 1183a904cd1a3b8f3cf219be9367701f; vterm = 0; term = 0; + { vval = 977400b12d4c3868588f1db7a6f272da; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }); (3: { vval = d41d8cd98f00b204e9800998ecf8427e; vterm = 0; term = 0; @@ -326,21 +326,21 @@ let%expect_test "e2e commit" = actions: [CommitCommands(Command(Read c1, 1)) Send(1,{ ctree = None; cons = - (Some { vval = 1183a904cd1a3b8f3cf219be9367701f; + (Some { vval = 977400b12d4c3868588f1db7a6f272da; vterm = 0; term = 0; - commit_index = 1183a904cd1a3b8f3cf219be9367701f }) + commit_index = 977400b12d4c3868588f1db7a6f272da }) }) Send(2,{ ctree = None; cons = - (Some { vval = 1183a904cd1a3b8f3cf219be9367701f; + (Some { vval = 977400b12d4c3868588f1db7a6f272da; vterm = 0; term = 0; - commit_index = 1183a904cd1a3b8f3cf219be9367701f }) + commit_index = 977400b12d4c3868588f1db7a6f272da }) }) Send(3,{ ctree = None; cons = - (Some { vval = 1183a904cd1a3b8f3cf219be9367701f; + (Some { vval = 977400b12d4c3868588f1db7a6f272da; vterm = 0; term = 0; - commit_index = 1183a904cd1a3b8f3cf219be9367701f }) + commit_index = 977400b12d4c3868588f1db7a6f272da }) })] |}] ; ignore (t0, t1) @@ -355,20 +355,22 @@ let%expect_test "e2e conflict resolution" = let t1, _ = Impl.advance t1 Tick in let t1, actions = Impl.advance t1 (Commands (Iter.of_list [c1])) in print t1 actions ; - [%expect {| + [%expect + {| + +Now leader for 0 t: { config = ; conspire = { rep = { state = - { vval = 620122743bc84de6b418bd632ea0cdc2; vterm = 0; term = 0; + { vval = e0622baa152ef15b905ad1cf0666001d; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }; store = { ctree = - [(620122743bc84de6b418bd632ea0cdc2: + [(d41d8cd98f00b204e9800998ecf8427e: Root); + (e0622baa152ef15b905ad1cf0666001d: { node = (1, d41d8cd98f00b204e9800998ecf8427e, [Command(Read c1, 2)]); - parent = ; key = 620122743bc84de6b418bd632ea0cdc2 }); - (d41d8cd98f00b204e9800998ecf8427e: Root)]; + parent = ; key = e0622baa152ef15b905ad1cf0666001d })]; root = d41d8cd98f00b204e9800998ecf8427e }; remotes = }; other_nodes_state = @@ -387,35 +389,35 @@ let%expect_test "e2e conflict resolution" = timeout = 2 } } actions: [Send(0,{ ctree = - (Some { new_head = 620122743bc84de6b418bd632ea0cdc2; + (Some { new_head = e0622baa152ef15b905ad1cf0666001d; extension = [(1, d41d8cd98f00b204e9800998ecf8427e, [Command(Read c1, 2)])] }); cons = - (Some { vval = 620122743bc84de6b418bd632ea0cdc2; + (Some { vval = e0622baa152ef15b905ad1cf0666001d; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }) }) Send(2,{ ctree = - (Some { new_head = 620122743bc84de6b418bd632ea0cdc2; + (Some { new_head = e0622baa152ef15b905ad1cf0666001d; extension = [(1, d41d8cd98f00b204e9800998ecf8427e, [Command(Read c1, 2)])] }); cons = - (Some { vval = 620122743bc84de6b418bd632ea0cdc2; + (Some { vval = e0622baa152ef15b905ad1cf0666001d; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }) }) Send(3,{ ctree = - (Some { new_head = 620122743bc84de6b418bd632ea0cdc2; + (Some { new_head = e0622baa152ef15b905ad1cf0666001d; extension = [(1, d41d8cd98f00b204e9800998ecf8427e, [Command(Read c1, 2)])] }); cons = - (Some { vval = 620122743bc84de6b418bd632ea0cdc2; + (Some { vval = e0622baa152ef15b905ad1cf0666001d; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }) })] |}] ; @@ -427,14 +429,14 @@ let%expect_test "e2e conflict resolution" = conspire = { rep = { state = - { vval = 1fddcd0db3e43a000153d0c4de56a7cc; vterm = 0; term = 0; + { vval = 875f3872edbe68ca2e42fd687213aa9c; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }; store = { ctree = - [(1fddcd0db3e43a000153d0c4de56a7cc: + [(875f3872edbe68ca2e42fd687213aa9c: { node = (1, d41d8cd98f00b204e9800998ecf8427e, [Command(Read c0, 1)]); - parent = ; key = 1fddcd0db3e43a000153d0c4de56a7cc }); + parent = ; key = 875f3872edbe68ca2e42fd687213aa9c }); (d41d8cd98f00b204e9800998ecf8427e: Root)]; root = d41d8cd98f00b204e9800998ecf8427e }; remotes = }; @@ -454,41 +456,41 @@ let%expect_test "e2e conflict resolution" = timeout = 2 } } actions: [Send(1,{ ctree = - (Some { new_head = 1fddcd0db3e43a000153d0c4de56a7cc; + (Some { new_head = 875f3872edbe68ca2e42fd687213aa9c; extension = [(1, d41d8cd98f00b204e9800998ecf8427e, [Command(Read c0, 1)])] }); cons = - (Some { vval = 1fddcd0db3e43a000153d0c4de56a7cc; + (Some { vval = 875f3872edbe68ca2e42fd687213aa9c; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }) }) Send(2,{ ctree = - (Some { new_head = 1fddcd0db3e43a000153d0c4de56a7cc; + (Some { new_head = 875f3872edbe68ca2e42fd687213aa9c; extension = [(1, d41d8cd98f00b204e9800998ecf8427e, [Command(Read c0, 1)])] }); cons = - (Some { vval = 1fddcd0db3e43a000153d0c4de56a7cc; + (Some { vval = 875f3872edbe68ca2e42fd687213aa9c; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }) }) Send(3,{ ctree = - (Some { new_head = 1fddcd0db3e43a000153d0c4de56a7cc; + (Some { new_head = 875f3872edbe68ca2e42fd687213aa9c; extension = [(1, d41d8cd98f00b204e9800998ecf8427e, [Command(Read c0, 1)])] }); cons = - (Some { vval = 1fddcd0db3e43a000153d0c4de56a7cc; + (Some { vval = 875f3872edbe68ca2e42fd687213aa9c; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }) })] |}] ; let root_clock = t0.conspire.rep.store.root in let c0_node = (1, root_clock, [c0]) in - let c0_clock = Md5.of_hex_exn "1fddcd0db3e43a000153d0c4de56a7cc" in + let c0_clock = MP.Conspire.CTree.make_key root_clock [c0] in let c1_node = (1, root_clock, [c1]) in let c1_clock = MP.Conspire.CTree.make_key root_clock [c1] in (* ---- Replicate tree ---- *) @@ -508,19 +510,19 @@ let%expect_test "e2e conflict resolution" = conspire = { rep = { state = - { vval = 1fddcd0db3e43a000153d0c4de56a7cc; vterm = 0; term = 0; + { vval = 875f3872edbe68ca2e42fd687213aa9c; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }; store = { ctree = - [(1fddcd0db3e43a000153d0c4de56a7cc: + [(875f3872edbe68ca2e42fd687213aa9c: { node = (1, d41d8cd98f00b204e9800998ecf8427e, [Command(Read c0, 1)]); - parent = ; key = 1fddcd0db3e43a000153d0c4de56a7cc }); - (620122743bc84de6b418bd632ea0cdc2: + parent = ; key = 875f3872edbe68ca2e42fd687213aa9c }); + (d41d8cd98f00b204e9800998ecf8427e: Root); + (e0622baa152ef15b905ad1cf0666001d: { node = (1, d41d8cd98f00b204e9800998ecf8427e, [Command(Read c1, 2)]); - parent = ; key = 620122743bc84de6b418bd632ea0cdc2 }); - (d41d8cd98f00b204e9800998ecf8427e: Root)]; + parent = ; key = e0622baa152ef15b905ad1cf0666001d })]; root = d41d8cd98f00b204e9800998ecf8427e }; remotes = }; other_nodes_state = @@ -572,31 +574,32 @@ let%expect_test "e2e conflict resolution" = print t0 actions ; [%expect {| + +Conflict, term=1 t: { config = ; conspire = { rep = { state = - { vval = 1fddcd0db3e43a000153d0c4de56a7cc; vterm = 0; term = 1; + { vval = 875f3872edbe68ca2e42fd687213aa9c; vterm = 0; term = 1; commit_index = d41d8cd98f00b204e9800998ecf8427e }; store = { ctree = - [(1fddcd0db3e43a000153d0c4de56a7cc: + [(875f3872edbe68ca2e42fd687213aa9c: { node = (1, d41d8cd98f00b204e9800998ecf8427e, [Command(Read c0, 1)]); - parent = ; key = 1fddcd0db3e43a000153d0c4de56a7cc }); - (620122743bc84de6b418bd632ea0cdc2: + parent = ; key = 875f3872edbe68ca2e42fd687213aa9c }); + (d41d8cd98f00b204e9800998ecf8427e: Root); + (e0622baa152ef15b905ad1cf0666001d: { node = (1, d41d8cd98f00b204e9800998ecf8427e, [Command(Read c1, 2)]); - parent = ; key = 620122743bc84de6b418bd632ea0cdc2 }); - (d41d8cd98f00b204e9800998ecf8427e: Root)]; + parent = ; key = e0622baa152ef15b905ad1cf0666001d })]; root = d41d8cd98f00b204e9800998ecf8427e }; remotes = }; other_nodes_state = [(1: - { vval = 620122743bc84de6b418bd632ea0cdc2; vterm = 0; term = 0; + { vval = e0622baa152ef15b905ad1cf0666001d; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }); (2: - { vval = 1fddcd0db3e43a000153d0c4de56a7cc; vterm = 0; term = 0; + { vval = 875f3872edbe68ca2e42fd687213aa9c; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }); (3: { vval = d41d8cd98f00b204e9800998ecf8427e; vterm = 0; term = 0; @@ -608,19 +611,19 @@ let%expect_test "e2e conflict resolution" = } actions: [Send(1,{ ctree = None; cons = - (Some { vval = 1fddcd0db3e43a000153d0c4de56a7cc; + (Some { vval = 875f3872edbe68ca2e42fd687213aa9c; vterm = 0; term = 1; commit_index = d41d8cd98f00b204e9800998ecf8427e }) }) Send(2,{ ctree = None; cons = - (Some { vval = 1fddcd0db3e43a000153d0c4de56a7cc; + (Some { vval = 875f3872edbe68ca2e42fd687213aa9c; vterm = 0; term = 1; commit_index = d41d8cd98f00b204e9800998ecf8427e }) }) Send(3,{ ctree = None; cons = - (Some { vval = 1fddcd0db3e43a000153d0c4de56a7cc; + (Some { vval = 875f3872edbe68ca2e42fd687213aa9c; vterm = 0; term = 1; commit_index = d41d8cd98f00b204e9800998ecf8427e }) })] |}] ; @@ -658,34 +661,35 @@ let%expect_test "e2e conflict resolution" = [%expect {| +Recovery complete term: {t:1,vt:1} + +Recovery to 1 t: { config = ; conspire = { rep = { state = - { vval = 1fddcd0db3e43a000153d0c4de56a7cc; vterm = 1; term = 1; + { vval = 875f3872edbe68ca2e42fd687213aa9c; vterm = 1; term = 1; commit_index = d41d8cd98f00b204e9800998ecf8427e }; store = { ctree = - [(1fddcd0db3e43a000153d0c4de56a7cc: + [(875f3872edbe68ca2e42fd687213aa9c: { node = (1, d41d8cd98f00b204e9800998ecf8427e, [Command(Read c0, 1)]); - parent = ; key = 1fddcd0db3e43a000153d0c4de56a7cc }); - (620122743bc84de6b418bd632ea0cdc2: + parent = ; key = 875f3872edbe68ca2e42fd687213aa9c }); + (d41d8cd98f00b204e9800998ecf8427e: Root); + (e0622baa152ef15b905ad1cf0666001d: { node = (1, d41d8cd98f00b204e9800998ecf8427e, [Command(Read c1, 2)]); - parent = ; key = 620122743bc84de6b418bd632ea0cdc2 }); - (d41d8cd98f00b204e9800998ecf8427e: Root)]; + parent = ; key = e0622baa152ef15b905ad1cf0666001d })]; root = d41d8cd98f00b204e9800998ecf8427e }; remotes = }; other_nodes_state = [(1: - { vval = 620122743bc84de6b418bd632ea0cdc2; vterm = 0; term = 0; + { vval = e0622baa152ef15b905ad1cf0666001d; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }); (2: - { vval = 1fddcd0db3e43a000153d0c4de56a7cc; vterm = 0; term = 1; + { vval = 875f3872edbe68ca2e42fd687213aa9c; vterm = 0; term = 1; commit_index = d41d8cd98f00b204e9800998ecf8427e }); (3: - { vval = 620122743bc84de6b418bd632ea0cdc2; vterm = 0; term = 1; + { vval = e0622baa152ef15b905ad1cf0666001d; vterm = 0; term = 1; commit_index = d41d8cd98f00b204e9800998ecf8427e })]; config = ; commit_log = [] }; failure_detector = @@ -694,19 +698,19 @@ let%expect_test "e2e conflict resolution" = } actions: [Send(1,{ ctree = None; cons = - (Some { vval = 1fddcd0db3e43a000153d0c4de56a7cc; + (Some { vval = 875f3872edbe68ca2e42fd687213aa9c; vterm = 1; term = 1; commit_index = d41d8cd98f00b204e9800998ecf8427e }) }) Send(2,{ ctree = None; cons = - (Some { vval = 1fddcd0db3e43a000153d0c4de56a7cc; + (Some { vval = 875f3872edbe68ca2e42fd687213aa9c; vterm = 1; term = 1; commit_index = d41d8cd98f00b204e9800998ecf8427e }) }) Send(3,{ ctree = None; cons = - (Some { vval = 1fddcd0db3e43a000153d0c4de56a7cc; + (Some { vval = 875f3872edbe68ca2e42fd687213aa9c; vterm = 1; term = 1; commit_index = d41d8cd98f00b204e9800998ecf8427e }) })] |}] ; @@ -718,10 +722,12 @@ let%expect_test "e2e conflict resolution" = ( Ok Rep. { ctree= Some {new_head= c0_clock; extension= [c0_node]} - ; cons= Some { vval= c0_clock + ; cons= + Some + { vval= c0_clock ; vterm= 0 ; term= 1 - ; commit_index= root_clock }} + ; commit_index= root_clock } } , 0 ) ) in let t1, actions = @@ -739,35 +745,38 @@ let%expect_test "e2e conflict resolution" = , 3 ) ) in print t1 actions ; - [%expect {| + [%expect + {| + +No longer leader for 1 + +Conflict, term=1 t: { config = ; conspire = { rep = { state = - { vval = 620122743bc84de6b418bd632ea0cdc2; vterm = 0; term = 1; + { vval = e0622baa152ef15b905ad1cf0666001d; vterm = 0; term = 1; commit_index = d41d8cd98f00b204e9800998ecf8427e }; store = { ctree = - [(1fddcd0db3e43a000153d0c4de56a7cc: + [(875f3872edbe68ca2e42fd687213aa9c: { node = (1, d41d8cd98f00b204e9800998ecf8427e, [Command(Read c0, 1)]); - parent = ; key = 1fddcd0db3e43a000153d0c4de56a7cc }); - (620122743bc84de6b418bd632ea0cdc2: + parent = ; key = 875f3872edbe68ca2e42fd687213aa9c }); + (d41d8cd98f00b204e9800998ecf8427e: Root); + (e0622baa152ef15b905ad1cf0666001d: { node = (1, d41d8cd98f00b204e9800998ecf8427e, [Command(Read c1, 2)]); - parent = ; key = 620122743bc84de6b418bd632ea0cdc2 }); - (d41d8cd98f00b204e9800998ecf8427e: Root)]; + parent = ; key = e0622baa152ef15b905ad1cf0666001d })]; root = d41d8cd98f00b204e9800998ecf8427e }; remotes = }; other_nodes_state = [(0: - { vval = 1fddcd0db3e43a000153d0c4de56a7cc; vterm = 0; term = 1; + { vval = 875f3872edbe68ca2e42fd687213aa9c; vterm = 0; term = 1; commit_index = d41d8cd98f00b204e9800998ecf8427e }); (2: { vval = d41d8cd98f00b204e9800998ecf8427e; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }); (3: - { vval = 620122743bc84de6b418bd632ea0cdc2; vterm = 0; term = 1; + { vval = e0622baa152ef15b905ad1cf0666001d; vterm = 0; term = 1; commit_index = d41d8cd98f00b204e9800998ecf8427e })]; config = ; commit_log = [] }; failure_detector = @@ -793,14 +802,14 @@ let%expect_test "message loss" = conspire = { rep = { state = - { vval = 1fddcd0db3e43a000153d0c4de56a7cc; vterm = 0; term = 0; + { vval = 875f3872edbe68ca2e42fd687213aa9c; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }; store = { ctree = - [(1fddcd0db3e43a000153d0c4de56a7cc: + [(875f3872edbe68ca2e42fd687213aa9c: { node = (1, d41d8cd98f00b204e9800998ecf8427e, [Command(Read c0, 1)]); - parent = ; key = 1fddcd0db3e43a000153d0c4de56a7cc }); + parent = ; key = 875f3872edbe68ca2e42fd687213aa9c }); (d41d8cd98f00b204e9800998ecf8427e: Root)]; root = d41d8cd98f00b204e9800998ecf8427e }; remotes = }; @@ -820,40 +829,40 @@ let%expect_test "message loss" = timeout = 2 } } actions: [Send(1,{ ctree = - (Some { new_head = 1fddcd0db3e43a000153d0c4de56a7cc; + (Some { new_head = 875f3872edbe68ca2e42fd687213aa9c; extension = [(1, d41d8cd98f00b204e9800998ecf8427e, [Command(Read c0, 1)])] }); cons = - (Some { vval = 1fddcd0db3e43a000153d0c4de56a7cc; + (Some { vval = 875f3872edbe68ca2e42fd687213aa9c; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }) }) Send(2,{ ctree = - (Some { new_head = 1fddcd0db3e43a000153d0c4de56a7cc; + (Some { new_head = 875f3872edbe68ca2e42fd687213aa9c; extension = [(1, d41d8cd98f00b204e9800998ecf8427e, [Command(Read c0, 1)])] }); cons = - (Some { vval = 1fddcd0db3e43a000153d0c4de56a7cc; + (Some { vval = 875f3872edbe68ca2e42fd687213aa9c; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }) }) Send(3,{ ctree = - (Some { new_head = 1fddcd0db3e43a000153d0c4de56a7cc; + (Some { new_head = 875f3872edbe68ca2e42fd687213aa9c; extension = [(1, d41d8cd98f00b204e9800998ecf8427e, [Command(Read c0, 1)])] }); cons = - (Some { vval = 1fddcd0db3e43a000153d0c4de56a7cc; + (Some { vval = 875f3872edbe68ca2e42fd687213aa9c; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }) })] |}] ; let root_clock = t0.conspire.rep.store.root in - let c0_clock = Md5.of_hex_exn "1fddcd0db3e43a000153d0c4de56a7cc" in + let c0_clock = MP.Conspire.CTree.make_key root_clock [c0] in let t0, _ = Impl.advance t0 (Recv @@ -889,14 +898,14 @@ let%expect_test "message loss" = conspire = { rep = { state = - { vval = 1fddcd0db3e43a000153d0c4de56a7cc; vterm = 0; term = 0; - commit_index = 1fddcd0db3e43a000153d0c4de56a7cc }; + { vval = 875f3872edbe68ca2e42fd687213aa9c; vterm = 0; term = 0; + commit_index = 875f3872edbe68ca2e42fd687213aa9c }; store = { ctree = - [(1fddcd0db3e43a000153d0c4de56a7cc: + [(875f3872edbe68ca2e42fd687213aa9c: { node = (1, d41d8cd98f00b204e9800998ecf8427e, [Command(Read c0, 1)]); - parent = ; key = 1fddcd0db3e43a000153d0c4de56a7cc }); + parent = ; key = 875f3872edbe68ca2e42fd687213aa9c }); (d41d8cd98f00b204e9800998ecf8427e: Root)]; root = d41d8cd98f00b204e9800998ecf8427e }; remotes = }; @@ -905,10 +914,10 @@ let%expect_test "message loss" = { vval = d41d8cd98f00b204e9800998ecf8427e; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }); (2: - { vval = 1fddcd0db3e43a000153d0c4de56a7cc; vterm = 0; term = 0; + { vval = 875f3872edbe68ca2e42fd687213aa9c; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }); (3: - { vval = 1fddcd0db3e43a000153d0c4de56a7cc; vterm = 0; term = 0; + { vval = 875f3872edbe68ca2e42fd687213aa9c; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e })]; config = ; commit_log = [[Command(Read c0, 1)]] }; failure_detector = @@ -918,21 +927,21 @@ let%expect_test "message loss" = actions: [CommitCommands(Command(Read c0, 1)) Send(1,{ ctree = None; cons = - (Some { vval = 1fddcd0db3e43a000153d0c4de56a7cc; + (Some { vval = 875f3872edbe68ca2e42fd687213aa9c; vterm = 0; term = 0; - commit_index = 1fddcd0db3e43a000153d0c4de56a7cc }) + commit_index = 875f3872edbe68ca2e42fd687213aa9c }) }) Send(2,{ ctree = None; cons = - (Some { vval = 1fddcd0db3e43a000153d0c4de56a7cc; + (Some { vval = 875f3872edbe68ca2e42fd687213aa9c; vterm = 0; term = 0; - commit_index = 1fddcd0db3e43a000153d0c4de56a7cc }) + commit_index = 875f3872edbe68ca2e42fd687213aa9c }) }) Send(3,{ ctree = None; cons = - (Some { vval = 1fddcd0db3e43a000153d0c4de56a7cc; + (Some { vval = 875f3872edbe68ca2e42fd687213aa9c; vterm = 0; term = 0; - commit_index = 1fddcd0db3e43a000153d0c4de56a7cc }) + commit_index = 875f3872edbe68ca2e42fd687213aa9c }) })] |}] ; let t0, actions = Impl.advance t0 (Commands (c1 |> Iter.singleton)) in print t0 actions ; @@ -942,18 +951,18 @@ let%expect_test "message loss" = conspire = { rep = { state = - { vval = b1d8bad167372c336ae91f91677feca1; vterm = 0; term = 0; - commit_index = 1fddcd0db3e43a000153d0c4de56a7cc }; + { vval = 11e8dcb4a482371b91ff2953cabcd7a6; vterm = 0; term = 0; + commit_index = 875f3872edbe68ca2e42fd687213aa9c }; store = { ctree = - [(1fddcd0db3e43a000153d0c4de56a7cc: + [(11e8dcb4a482371b91ff2953cabcd7a6: { node = - (1, d41d8cd98f00b204e9800998ecf8427e, [Command(Read c0, 1)]); - parent = ; key = 1fddcd0db3e43a000153d0c4de56a7cc }); - (b1d8bad167372c336ae91f91677feca1: + (2, 875f3872edbe68ca2e42fd687213aa9c, [Command(Read c1, 2)]); + parent = ; key = 11e8dcb4a482371b91ff2953cabcd7a6 }); + (875f3872edbe68ca2e42fd687213aa9c: { node = - (2, 1fddcd0db3e43a000153d0c4de56a7cc, [Command(Read c1, 2)]); - parent = ; key = b1d8bad167372c336ae91f91677feca1 }); + (1, d41d8cd98f00b204e9800998ecf8427e, [Command(Read c0, 1)]); + parent = ; key = 875f3872edbe68ca2e42fd687213aa9c }); (d41d8cd98f00b204e9800998ecf8427e: Root)]; root = d41d8cd98f00b204e9800998ecf8427e }; remotes = }; @@ -962,10 +971,10 @@ let%expect_test "message loss" = { vval = d41d8cd98f00b204e9800998ecf8427e; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }); (2: - { vval = 1fddcd0db3e43a000153d0c4de56a7cc; vterm = 0; term = 0; + { vval = 875f3872edbe68ca2e42fd687213aa9c; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }); (3: - { vval = 1fddcd0db3e43a000153d0c4de56a7cc; vterm = 0; term = 0; + { vval = 875f3872edbe68ca2e42fd687213aa9c; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e })]; config = ; commit_log = [[Command(Read c0, 1)]] }; failure_detector = @@ -973,39 +982,39 @@ let%expect_test "message loss" = timeout = 2 } } actions: [Send(1,{ ctree = - (Some { new_head = b1d8bad167372c336ae91f91677feca1; + (Some { new_head = 11e8dcb4a482371b91ff2953cabcd7a6; extension = - [(2, 1fddcd0db3e43a000153d0c4de56a7cc, + [(2, 875f3872edbe68ca2e42fd687213aa9c, [Command(Read c1, 2)])] }); cons = - (Some { vval = b1d8bad167372c336ae91f91677feca1; + (Some { vval = 11e8dcb4a482371b91ff2953cabcd7a6; vterm = 0; term = 0; - commit_index = 1fddcd0db3e43a000153d0c4de56a7cc }) + commit_index = 875f3872edbe68ca2e42fd687213aa9c }) }) Send(2,{ ctree = - (Some { new_head = b1d8bad167372c336ae91f91677feca1; + (Some { new_head = 11e8dcb4a482371b91ff2953cabcd7a6; extension = - [(2, 1fddcd0db3e43a000153d0c4de56a7cc, + [(2, 875f3872edbe68ca2e42fd687213aa9c, [Command(Read c1, 2)])] }); cons = - (Some { vval = b1d8bad167372c336ae91f91677feca1; + (Some { vval = 11e8dcb4a482371b91ff2953cabcd7a6; vterm = 0; term = 0; - commit_index = 1fddcd0db3e43a000153d0c4de56a7cc }) + commit_index = 875f3872edbe68ca2e42fd687213aa9c }) }) Send(3,{ ctree = - (Some { new_head = b1d8bad167372c336ae91f91677feca1; + (Some { new_head = 11e8dcb4a482371b91ff2953cabcd7a6; extension = - [(2, 1fddcd0db3e43a000153d0c4de56a7cc, + [(2, 875f3872edbe68ca2e42fd687213aa9c, [Command(Read c1, 2)])] }); cons = - (Some { vval = b1d8bad167372c336ae91f91677feca1; + (Some { vval = 11e8dcb4a482371b91ff2953cabcd7a6; vterm = 0; term = 0; - commit_index = 1fddcd0db3e43a000153d0c4de56a7cc }) + commit_index = 875f3872edbe68ca2e42fd687213aa9c }) })] |}] ; - let c1_clock = Md5.of_hex_exn "b1d8bad167372c336ae91f91677feca1" in + let c1_clock = MP.Conspire.CTree.make_key root_clock [c1] in let update = Ok MP.Conspire.Rep. @@ -1017,7 +1026,7 @@ let%expect_test "message loss" = print t1 actions ; [%expect {| - +Nack: Update is not rooted + +Nack for 0: Update is not rooted t: { config = ; conspire = { rep = @@ -1051,22 +1060,23 @@ let%expect_test "message loss" = (* note extension goes from the erroneous commit index *) [%expect {| + +Acking 1 t: { config = ; conspire = { rep = { state = - { vval = b1d8bad167372c336ae91f91677feca1; vterm = 0; term = 0; - commit_index = 1fddcd0db3e43a000153d0c4de56a7cc }; + { vval = 11e8dcb4a482371b91ff2953cabcd7a6; vterm = 0; term = 0; + commit_index = 875f3872edbe68ca2e42fd687213aa9c }; store = { ctree = - [(1fddcd0db3e43a000153d0c4de56a7cc: + [(11e8dcb4a482371b91ff2953cabcd7a6: { node = - (1, d41d8cd98f00b204e9800998ecf8427e, [Command(Read c0, 1)]); - parent = ; key = 1fddcd0db3e43a000153d0c4de56a7cc }); - (b1d8bad167372c336ae91f91677feca1: + (2, 875f3872edbe68ca2e42fd687213aa9c, [Command(Read c1, 2)]); + parent = ; key = 11e8dcb4a482371b91ff2953cabcd7a6 }); + (875f3872edbe68ca2e42fd687213aa9c: { node = - (2, 1fddcd0db3e43a000153d0c4de56a7cc, [Command(Read c1, 2)]); - parent = ; key = b1d8bad167372c336ae91f91677feca1 }); + (1, d41d8cd98f00b204e9800998ecf8427e, [Command(Read c0, 1)]); + parent = ; key = 875f3872edbe68ca2e42fd687213aa9c }); (d41d8cd98f00b204e9800998ecf8427e: Root)]; root = d41d8cd98f00b204e9800998ecf8427e }; remotes = }; @@ -1075,10 +1085,10 @@ let%expect_test "message loss" = { vval = d41d8cd98f00b204e9800998ecf8427e; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }); (2: - { vval = 1fddcd0db3e43a000153d0c4de56a7cc; vterm = 0; term = 0; + { vval = 875f3872edbe68ca2e42fd687213aa9c; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e }); (3: - { vval = 1fddcd0db3e43a000153d0c4de56a7cc; vterm = 0; term = 0; + { vval = 875f3872edbe68ca2e42fd687213aa9c; vterm = 0; term = 0; commit_index = d41d8cd98f00b204e9800998ecf8427e })]; config = ; commit_log = [[Command(Read c0, 1)]] }; failure_detector = @@ -1086,11 +1096,11 @@ let%expect_test "message loss" = timeout = 2 } } actions: [Send(1,{ ctree = - (Some { new_head = b1d8bad167372c336ae91f91677feca1; + (Some { new_head = 11e8dcb4a482371b91ff2953cabcd7a6; extension = [(1, d41d8cd98f00b204e9800998ecf8427e, [Command(Read c0, 1)]); - (2, 1fddcd0db3e43a000153d0c4de56a7cc, + (2, 875f3872edbe68ca2e42fd687213aa9c, [Command(Read c1, 2)]) ] }); diff --git a/lib/client.ml b/lib/client.ml index 6fb0ce6..0199af5 100644 --- a/lib/client.ml +++ b/lib/client.ml @@ -102,7 +102,7 @@ let send_request ?(random_id = false) t op = if random_id then Random.int32 Int32.max_int |> Int32.to_int else t.next_id () in - let command = Command.{op; id; trace_start= Unix.gettimeofday ()} in + let command = Command.{op; id; submitted= Unix.gettimeofday (); trace_start= Unix.gettimeofday ()} in let send () = submit_request t.cmgr command in let res_t, res_u = Promise.create () in let request_state = diff --git a/lib/internal_infra.ml b/lib/internal_infra.ml index 1febe16..807ebab 100644 --- a/lib/internal_infra.ml +++ b/lib/internal_infra.ml @@ -254,11 +254,12 @@ module Test = struct Command. { op= Write (k, n) ; id= Core.Random.int Core.Int.max_value - ; trace_start= -1. } + ; trace_start= -1. + ; submitted= -1.} let r n = Command. - {op= Read n; id= Core.Random.int Core.Int.max_value; trace_start= -1.} + {op= Read n; id= Core.Random.int Core.Int.max_value; trace_start= -1.; submitted = -1.} module CT : Consensus_intf.S = struct type message = Core.String.t [@@deriving sexp] diff --git a/lib/line_prot.ml b/lib/line_prot.ml index bfad270..db2a3d9 100644 --- a/lib/line_prot.ml +++ b/lib/line_prot.ml @@ -27,8 +27,9 @@ module SerPrim = struct | NoOp -> () - let command Command.{op; id; trace_start} w = + let command Command.{op; id; submitted; trace_start} w = W.BE.uint64 w (Int64.of_int id) ; + W.BE.double w submitted ; W.BE.double w trace_start ; sm_op op w @@ -85,9 +86,10 @@ module DeserPrim = struct let command = let* id = R.map Int64.to_int R.BE.uint64 + and* submitted = R.BE.double and* trace_start = R.BE.double and* op = sm_op in - R.return Command.{op; id; trace_start} + R.return Command.{op; id; submitted; trace_start} let log_entry = let* term = R.map Int64.to_int R.BE.uint64 and* command = command in diff --git a/lib/types.ml b/lib/types.ml index 04ba7d9..c7767e1 100644 --- a/lib/types.ml +++ b/lib/types.ml @@ -40,7 +40,8 @@ let sm_op_pp ppf v = module Command = struct module T = struct - type t = {op: sm_op; id: command_id; mutable trace_start: float} + type t = + {op: sm_op; id: command_id; submitted: float; mutable trace_start: float} [@@deriving sexp, bin_io] let hash t = hash_command_id t.id @@ -48,7 +49,7 @@ module Command = struct let hash_fold_t s t = hash_fold_command_id s t.id let pp_mach ppf v = - Fmt.pf ppf "Command(%a, %d, %.4f)" sm_op_pp v.op v.id v.trace_start + Fmt.pf ppf "Command(%a, %d, %.4f, %.4f)" sm_op_pp v.op v.id v.submitted v.trace_start let pp ppf v = Fmt.pf ppf "Command(%a, %d)" sm_op_pp v.op v.id @@ -67,15 +68,16 @@ let update_command_time c = c.Command.trace_start <- Core_unix.gettimeofday () let get_command_trace_time c = c.Command.trace_start -let empty_command = Command.{op= NoOp; id= -1; trace_start= -1.} +let empty_command = Command.{op= NoOp; id= -1; submitted= -1.; trace_start= -1.} let make_command_state = ref 0 let reset_make_command_state () = make_command_state := 0 +(* Used for tests *) let make_command c = make_command_state := !make_command_state + 1 ; - Command.{op= c; id= !make_command_state; trace_start= -1.} + Command.{op= c; id= !make_command_state; trace_start= -1.; submitted= -1.} type op_result = Success | Failure of string | ReadSuccess of key [@@deriving bin_io]