From 041114022b311bd62df44c8ba1a958647f0349e2 Mon Sep 17 00:00:00 2001 From: Nikolai Golub Date: Sat, 23 Mar 2024 15:17:04 +0100 Subject: [PATCH] jmt: use `borsh@1.3.0` (#109) * Upgrade to borsh 1.3.0 * Fix formatting --- Cargo.toml | 2 +- src/node_type.rs | 1 + src/types/proof/definition.rs | 8 ++++---- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 906937d..71906e6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ migration = [] [dependencies] anyhow = "1.0.38" -borsh = "0.10.0" +borsh = { version = "1.3.0" , features = ["derive", "de_strict_order"]} digest = "0.10" hashbrown = "0.13.2" itertools = { version = "0.10.0", default-features = false } diff --git a/src/node_type.rs b/src/node_type.rs index 88de3b7..33fa74c 100644 --- a/src/node_type.rs +++ b/src/node_type.rs @@ -867,6 +867,7 @@ impl From for SparseMerkleLeafNode { #[repr(u8)] #[derive(FromPrimitive, ToPrimitive, BorshDeserialize, BorshSerialize)] +#[borsh(use_discriminant = false)] enum NodeTag { Null = 0, Leaf = 1, diff --git a/src/types/proof/definition.rs b/src/types/proof/definition.rs index db7d3e9..79bf519 100644 --- a/src/types/proof/definition.rs +++ b/src/types/proof/definition.rs @@ -741,9 +741,9 @@ mod serialization_tests { #[test] fn test_sparse_merkle_proof_roundtrip_borsh() { - use borsh::{BorshDeserialize, BorshSerialize}; + use borsh::BorshDeserialize; let proof = get_test_proof(); - let serialized_proof = proof.try_to_vec().expect("serialization is infallible"); + let serialized_proof = borsh::to_vec(&proof).expect("serialization is infallible"); let deserialized = SparseMerkleProof::::deserialize(&mut serialized_proof.as_slice()) .expect("serialized proof is valid"); @@ -763,9 +763,9 @@ mod serialization_tests { #[test] fn test_sparse_merkle_range_proof_roundtrip_borsh() { - use borsh::{BorshDeserialize, BorshSerialize}; + use borsh::BorshDeserialize; let proof = get_test_range_proof(); - let serialized_proof = proof.try_to_vec().expect("serialization is infallible"); + let serialized_proof = borsh::to_vec(&proof).expect("serialization is infallible"); let deserialized = SparseMerkleRangeProof::::deserialize(&mut serialized_proof.as_slice()) .expect("serialized proof is valid");