mina_tree/dummy/
mod.rs

1use std::sync::Arc;
2
3use mina_p2p_messages::{binprot::BinProtRead, v2::PicklesProofProofsVerifiedMaxStableV2};
4
5pub use openmina_core::dummy::*;
6
7#[cfg(any(test, feature = "fuzzing"))]
8use crate::VerificationKey;
9
10#[cfg(any(test, feature = "fuzzing"))]
11pub mod for_tests;
12
13/// Value of `vk` when we run `dune runtest src/lib/staged_ledger -f`
14/// <https://github.com/MinaProtocol/mina/blob/3753a8593cc1577bcf4da16620daf9946d88e8e5/src/lib/staged_ledger/staged_ledger.ml#L2083>
15///
16/// The file was generated this way:
17///
18/// let buf = Bigstring.create (Side_loaded_verification_key.Stable.V2.bin_size_t vk.data) in
19/// ignore (Side_loaded_verification_key.Stable.V2.bin_write_t buf ~pos:0 vk.data : int) ;
20/// let bytes = Bigstring.to_bytes buf in
21/// let explode s = List.init (String.length s) ~f:(fun i -> String.get s i) in
22/// let s = (String.concat ~sep:"," (List.map (explode (Bytes.to_string bytes)) ~f:(fun b -> string_of_int (Char.to_int b)))) in
23///
24/// Core.Printf.eprintf !"vk=%{sexp: (Side_loaded_verification_key.t, Frozen_ledger_hash.t) With_hash.t}\n%!" vk;
25/// Core.Printf.eprintf !"vk_binprot=[%s]\n%!" s;
26#[cfg(any(test, feature = "fuzzing"))] // Used for tests/fuzzing only
27pub fn trivial_verification_key() -> VerificationKey {
28    use mina_p2p_messages::v2::MinaBaseVerificationKeyWireStableV1;
29
30    let mut cursor = std::io::Cursor::new(include_bytes!("trivial_vk.bin"));
31    let vk = MinaBaseVerificationKeyWireStableV1::binprot_read(&mut cursor).unwrap();
32
33    let vk: VerificationKey = (&vk).try_into().unwrap();
34    vk
35}
36
37/// Value of a dummy proof when we run `dune runtest src/lib/staged_ledger -f`
38/// <https://github.com/MinaProtocol/mina/blob/d7dad23d8ea2052f515f5d55d187788fe0701c7f/src/lib/mina_base/control.ml#L94>
39///
40/// The file was generated this way:
41///
42/// let buf = Bigstring.create (Pickles.Proof.Proofs_verified_2.Stable.V2.bin_size_t proof) in
43/// ignore (Pickles.Proof.Proofs_verified_2.Stable.V2.bin_write_t buf ~pos:0 proof : int) ;
44/// let bytes = Bigstring.to_bytes buf in
45/// let explode s = List.init (String.length s) ~f:(fun i -> String.get s i) in
46/// let s = (String.concat ~sep:"," (List.map (explode (Bytes.to_string bytes)) ~f:(fun b -> string_of_int (Char.to_int b)))) in
47///
48/// Printf.eprintf !"proof_sexp=%{sexp: Pickles.Proof.Proofs_verified_2.Stable.V2.t}\n%!" proof;
49/// Printf.eprintf !"proof_binprot=[%s]\n%!" s;
50pub fn sideloaded_proof() -> Arc<PicklesProofProofsVerifiedMaxStableV2> {
51    let mut cursor = std::io::Cursor::new(include_bytes!("sideloaded_proof.bin"));
52    let proof = PicklesProofProofsVerifiedMaxStableV2::binprot_read(&mut cursor).unwrap();
53
54    Arc::new(proof)
55}