Skip to content

Commit

Permalink
Remove Stream Proofs (#2275)
Browse files Browse the repository at this point in the history
* Remove Stream Proofs

They are hard to maintain and nobdy use those anymore.

* Update CHANGES
  • Loading branch information
samoht authored Oct 2, 2023
1 parent e24b729 commit 2e7a6a2
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 842 deletions.
8 changes: 6 additions & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
- **irmin-http**
- Removed `irmin-http` since it is not compatible with generic keys.
`irmin-grapqhl` or `irmin-server` should be used instead. (#1902, @zshipko)
- **irmin**
- Removed stream proofs. We now only have Merkle tree proofs. This simplifies
the maintenance of that part of the code, as ensuring the correct order of
cached IO operations was tricky for stream proofs (#2275, @samoht)

## 3.8.0 (2023-07-06)

Expand All @@ -30,7 +34,7 @@
- Change behavior of `Irmin.Conf.key` to disallow duplicate key names by
default. Add `allow_duplicate` optional argument to override. (#2252,
@metanivek)

- **irmin-pack**
- Add maximum memory as an alternative configuration option, `lru_max_memory`,
for setting LRU capacity. (@metanivek, #2254)
Expand All @@ -51,7 +55,7 @@
- **irmin-cli**
- Changed `--store irf` to `--store fs` to align the CLI with what is
published on the Irmin website (#2243, @wyn)

## 3.7.2 (2023-06-16)

### Fixed
Expand Down
4 changes: 2 additions & 2 deletions examples/merkle_proofs.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ Here is the signature of `produce_proof`:
val produce_proof :
Store.repo ->
Store.Tree.kinded_key ->
(Store.tree -> (Store.tree * 'a) Lwt.t) ->
(Store.Tree.Proof.tree Store.Tree.Proof.t * 'a) Lwt.t = <fun>
(Store.tree -> (Store.tree * 'a) Lwt.t) -> (Store.Tree.Proof.t * 'a) Lwt.t =
<fun>
```

`produce_proof repo key_before f` is `(proof = { state; hash_before; hash_after }, f_res)`. `f` is invoked once per call to `produce_proof` and `f tree_before` is `(tree_after, f_res)`.
Expand Down
57 changes: 1 addition & 56 deletions src/irmin-test/store.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1454,8 +1454,7 @@ module Make (S : Generic_key) = struct
in
run x test

let pp_proof = Irmin.Type.pp (S.Tree.Proof.t S.Tree.Proof.tree_t)
let pp_stream = Irmin.Type.pp (S.Tree.Proof.t S.Tree.Proof.stream_t)
let pp_proof = Irmin.Type.pp S.Tree.Proof.t

let test_proofs x () =
let test repo =
Expand Down Expand Up @@ -1656,19 +1655,6 @@ module Make (S : Generic_key) = struct
in
let* () = Lwt_list.iter_s check_proof [ f0; f1 ] in

let check_stream f =
let* p, () = S.Tree.produce_stream repo key f in
[%log.debug "Verifying stream %a" pp_stream p];
let+ r = S.Tree.verify_stream p f in
match r with
| Ok (_, ()) -> ()
| Error e ->
Alcotest.failf "check_stream: %a"
(Irmin.Type.pp S.Tree.verifier_error_t)
e
in
let* () = Lwt_list.iter_s check_stream [ f0; f1 ] in

(* check env sharing *)
let tree () =
S.Tree.of_concrete
Expand Down Expand Up @@ -1764,47 +1750,6 @@ module Make (S : Generic_key) = struct
(fun c -> check_bad_proof (proof ~state:c ()))
some_contents
in

(* test negative streams *)
let check_bad_stream p =
let+ r = S.Tree.verify_stream p f0 in
match r with
| Ok _ ->
Alcotest.failf "verify_stream should have failed %a" pp_stream p
| Error _ -> ()
in

let* p0, () = S.Tree.produce_stream repo key f0 in
let proof ?(before = S.Tree.Proof.before p0)
?(after = S.Tree.Proof.after p0) ?(contents = S.Tree.Proof.state p0)
() =
S.Tree.Proof.v ~before ~after contents
in
let wrong_hash = B.Contents.Hash.hash "not the right hash!" in
let wrong_kinded_hash = `Node wrong_hash in
let* () = check_bad_stream (proof ~before:wrong_kinded_hash ()) in
let* () = check_bad_stream (proof ~after:wrong_kinded_hash ()) in
let* _ = S.Tree.verify_stream (proof ()) f0 in
let some_contents : S.Tree.Proof.stream list =
let s : S.Tree.Proof.elt list -> S.Tree.Proof.stream = List.to_seq in
let ok = List.of_seq (S.Tree.Proof.state p0) in
[
s [];
s [ Node [] ];
s [ Inode { length = 1024; proofs = [] } ];
s [ Contents "yo" ];
s (ok @ [ Node [] ]);
]
in
let* () =
let x = ref 1 in
Lwt_list.iter_s
(fun c ->
incr x;
check_bad_stream (proof ~contents:c ()))
some_contents
in

B.Repo.close repo
in
run x test
Expand Down
Loading

0 comments on commit 2e7a6a2

Please sign in to comment.