diff --git a/Cargo.lock b/Cargo.lock index 068f7a55..b0f83626 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5994,9 +5994,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.95" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e" +checksum = "a474f6281d1d70c17ae7aa6a613c87fce69a127e2624002df63dcb39d6cf6396" dependencies = [ "cfg-if", "once_cell", @@ -6005,13 +6005,12 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.95" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358" +checksum = "5f89bb38646b4f81674e8f5c3fb81b562be1fd936d84320f3264486418519c79" dependencies = [ "bumpalo", "log", - "once_cell", "proc-macro2", "quote", "syn 2.0.87", @@ -6032,9 +6031,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.95" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56" +checksum = "2cc6181fd9a7492eef6fef1f33961e3695e4579b9872a6f7c83aee556666d4fe" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -6042,9 +6041,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.95" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" +checksum = "30d7a95b763d3c45903ed6c81f156801839e5ee968bb07e534c44df0fcd330c2" dependencies = [ "proc-macro2", "quote", @@ -6055,9 +6054,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.95" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" +checksum = "943aab3fdaaa029a6e0271b35ea10b72b943135afe9bffca82384098ad0e06a6" [[package]] name = "wasm-bindgen-test" diff --git a/grpc/tests/tonic.rs b/grpc/tests/tonic.rs index d17cea35..74207c4f 100644 --- a/grpc/tests/tonic.rs +++ b/grpc/tests/tonic.rs @@ -1,5 +1,4 @@ #![cfg(not(target_arch = "wasm32"))] -//! gRPC tests use celestia_grpc::types::auth::Account; use celestia_grpc::types::tx::sign_tx; diff --git a/grpc/tests/utils/mod.rs b/grpc/tests/utils/mod.rs index 8289c5d7..91872634 100644 --- a/grpc/tests/utils/mod.rs +++ b/grpc/tests/utils/mod.rs @@ -1,5 +1,4 @@ #![cfg(not(target_arch = "wasm32"))] -//! Utilities for grpc tests use std::{env, fs}; diff --git a/node-wasm/Cargo.toml b/node-wasm/Cargo.toml index 0349c980..d0d2788a 100644 --- a/node-wasm/Cargo.toml +++ b/node-wasm/Cargo.toml @@ -46,7 +46,7 @@ tokio = { version = "1.38.0", features = ["sync"] } tracing = "0.1.40" tracing-subscriber = { version = "0.3.18", features = ["time"] } tracing-web = "0.1.3" -wasm-bindgen = "0.2.95" +wasm-bindgen = "0.2.93" wasm-bindgen-futures = "0.4.43" web-sys = { version = "0.3.70", features = [ "BroadcastChannel", diff --git a/node/Cargo.toml b/node/Cargo.toml index db7f548c..38ba4d8a 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -89,7 +89,7 @@ pin-project = "1.1.5" rexie = "0.6.2" send_wrapper = { version = "0.6.0", features = ["futures"] } serde-wasm-bindgen = "0.6.5" -wasm-bindgen = "0.2.97" +wasm-bindgen = "0.2.93" wasm-bindgen-futures = "0.4.43" libp2p-websocket-websys = "0.3.3" diff --git a/rpc/tests/blob.rs b/rpc/tests/blob.rs index 35b75015..1789692f 100644 --- a/rpc/tests/blob.rs +++ b/rpc/tests/blob.rs @@ -6,7 +6,7 @@ use std::time::Duration; use celestia_rpc::blob::BlobsAtHeight; use celestia_rpc::prelude::*; use celestia_types::consts::appconsts::AppVersion; -use celestia_types::Blob; +use celestia_types::{Blob, Commitment}; use jsonrpsee::core::client::Subscription; pub mod utils; @@ -194,7 +194,7 @@ async fn blob_get_get_proof_wrong_commitment() { let namespace = random_ns(); let data = random_bytes(5); let blob = Blob::new(namespace, data, AppVersion::V2).unwrap(); - let commitment = random_bytes_array().into(); + let commitment = Commitment::new(random_bytes_array()); let submitted_height = blob_submit(&client, &[blob.clone()]).await.unwrap(); diff --git a/types/src/blob.rs b/types/src/blob.rs index 7cef810d..e12eff10 100644 --- a/types/src/blob.rs +++ b/types/src/blob.rs @@ -401,7 +401,7 @@ mod tests { #[test] fn validate_blob_commitment_mismatch() { let mut blob = sample_blob(); - blob.commitment = [7; 32].into(); + blob.commitment = Commitment::new([7; 32]); blob.validate(AppVersion::V2).unwrap_err(); } diff --git a/types/src/blob/commitment.rs b/types/src/blob/commitment.rs index d739fb18..69f2c48b 100644 --- a/types/src/blob/commitment.rs +++ b/types/src/blob/commitment.rs @@ -16,6 +16,8 @@ use crate::nmt::{Namespace, NamespacedHashExt, NamespacedSha2Hasher, Nmt, RawNam use crate::{Error, Result}; use crate::{InfoByte, Share}; +// TODO: once https://github.com/rustwasm/wasm-bindgen/pull/4351 is merged, +// this can be replaced with a single common type definition /// A merkle hash used to identify the [`Blob`]s data. /// /// In Celestia network, the transaction which pays for the blob's inclusion @@ -56,11 +58,15 @@ use crate::{InfoByte, Share}; #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] pub struct Commitment { /// hash of the commitment - #[cfg_attr(all(feature = "wasm-bindgen", target_arch = "wasm32"), wasm_bindgen(skip))] hash: merkle::Hash, } impl Commitment { + /// Create a new commitment with hash + pub fn new(hash: merkle::Hash) -> Self { + Commitment { hash } + } + /// Generate the share commitment from the given blob data. pub fn from_blob( namespace: Namespace, @@ -133,12 +139,6 @@ impl From for merkle::Hash { } } -impl From for Commitment { - fn from(hash: merkle::Hash) -> Self { - Commitment { hash } - } -} - impl Serialize for Commitment { fn serialize(&self, serializer: S) -> Result where diff --git a/types/src/blob/msg_pay_for_blobs.rs b/types/src/blob/msg_pay_for_blobs.rs index 45bbf8b9..914486ef 100644 --- a/types/src/blob/msg_pay_for_blobs.rs +++ b/types/src/blob/msg_pay_for_blobs.rs @@ -81,7 +81,7 @@ impl From for RawMsgPayForBlobs { let share_commitments = msg .share_commitments .into_iter() - .map(|c| Hash::from(c).to_vec()) + .map(|c| c.hash().to_vec()) .collect(); RawMsgPayForBlobs { @@ -108,7 +108,7 @@ impl TryFrom for MsgPayForBlobs { .into_iter() .map(|c| { let hash = Hash::try_from(c).map_err(|_| Error::InvalidComittmentLength)?; - Ok(hash.into()) + Ok(Commitment::new(hash)) }) .collect::>()?;