diff --git a/README.md b/README.md index 4d66f7f9..d55137b1 100644 --- a/README.md +++ b/README.md @@ -237,10 +237,6 @@ From here we can build: There is a work in progress implementation of a debugger layer for GroveDB. To use this library with these capabilities enabled one needs to set a dependency with `grovedbg` feature. -At build time this requires two environment dependencies: -1. `wasm32-unknown-unknown` Rust toolchain; -2. [trunk](https://trunkrs.dev/) utility. - Then, to launch visualizer tool to observe the database structure inside of your browser on a port, let's say 10000, the following snippet should do: diff --git a/grovedb/Cargo.toml b/grovedb/Cargo.toml index 57a27479..0b871cf2 100644 --- a/grovedb/Cargo.toml +++ b/grovedb/Cargo.toml @@ -26,7 +26,7 @@ nohash-hasher = { version = "0.2.0", optional = true } indexmap = { version = "2.2.6"} intmap = { version = "2.0.0", optional = true } grovedb-path = { version = "1.0.0-rc.2", path = "../path" } -grovedbg-types = { path = "../grovedbg-types", optional = true } +grovedbg-types = { version = "1.0.0-rc.2", path = "../grovedbg-types", optional = true } tokio = { version = "1.37.0", features = ["rt-multi-thread", "net"], optional = true } axum = { version = "0.7.5", features = ["macros"], optional = true } tower-http = { version = "0.5.2", features = ["fs"], optional = true } @@ -82,4 +82,6 @@ grovedbg = [ ] [build-dependencies] -zip-extensions = "0.6.2" +hex-literal = "0.4.1" +reqwest = { version = "0.12.5", features = ["blocking"] } +sha2 = "0.10.8" diff --git a/grovedb/build.rs b/grovedb/build.rs index cbdc11ac..d7b4b7b9 100644 --- a/grovedb/build.rs +++ b/grovedb/build.rs @@ -1,36 +1,33 @@ #[cfg(feature = "grovedbg")] fn main() { - use std::{ - env, - path::PathBuf, - process::{Command, ExitStatus, Output}, - }; + use std::{env, fs::File, io::Cursor, path::PathBuf}; + + use hex_literal::hex; + use sha2::{digest::FixedOutput, Digest, Sha256}; + + const GROVEDBG_SHA256: [u8; 32] = + hex!("206d865949e7f12b843c342cea3b172d4c78d4eb754b80d272164d59f62a2276"); + const GROVEDBG_VERSION: &str = "v1.0.0-rc.3"; let out_dir = PathBuf::from(&env::var_os("OUT_DIR").unwrap()); + let grovedbg_zip_path = out_dir.join("grovedbg.zip"); + + if !grovedbg_zip_path.exists() { + let response = reqwest::blocking::get(format!("https://github.com/dashpay/grovedbg/releases/download/{GROVEDBG_VERSION}/grovedbg-{GROVEDBG_VERSION}.zip")) + .expect("can't download GroveDBG artifact"); - let Output { - status, - stdout, - stderr, - } = Command::new("trunk") - .arg("build") - .arg("--release") - .arg("--dist") - .arg(&out_dir) - .arg("grovedbg/index.html") - .output() - .expect("cannot start trunk process"); - - if !status.success() { - let stdout_msg = String::from_utf8_lossy(&stdout); - let stderr_msg = String::from_utf8_lossy(&stderr); - let bindgen_version = env::var_os("TRUNK_TOOLS_WASM_BINDGEN").unwrap_or_default(); - panic!("Error running `trunk build --release`\nbindgen version:{bindgen_version:?}\n{stdout_msg}\n{stderr_msg}"); + let mut grovedbg_zip = File::create(&grovedbg_zip_path).unwrap(); + let mut content = Cursor::new(response.bytes().unwrap()); + std::io::copy(&mut content, &mut grovedbg_zip).unwrap(); } - let zip_file = out_dir.join("grovedbg.zip"); - zip_extensions::write::zip_create_from_directory(&zip_file, &out_dir) - .expect("can't create a grovedbg zip archive"); + let mut grovedbg_zip = File::open(&grovedbg_zip_path).unwrap(); + + let mut sha256 = Sha256::new(); + std::io::copy(&mut grovedbg_zip, &mut sha256).unwrap(); + let hash = sha256.finalize_fixed(); + + assert_eq!(hash.as_slice(), GROVEDBG_SHA256); } #[cfg(not(feature = "grovedbg"))] diff --git a/grovedbg-types/Cargo.toml b/grovedbg-types/Cargo.toml index 300eb5c7..a3a2878e 100644 --- a/grovedbg-types/Cargo.toml +++ b/grovedbg-types/Cargo.toml @@ -1,7 +1,11 @@ [package] name = "grovedbg-types" -version = "0.1.0" +version = "1.0.0-rc.2" edition = "2021" +description = "Common type definitions for data exchange over GroveDBG protocol" +authors = ["Evgeny Fomin "] +license = "MIT" +repository = "https://github.com/dashpay/grovedb" [dependencies] serde = { version = "1.0.201", features = ["derive"] }