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");