Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Borsh 09 feature #61

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ codegen-units = 1
anchor-lang = {version = "0.28.0", features = ["init-if-needed"]}
base64 = { version = "0.21", default-features = false, features = ["alloc"] }
borsh = { version = "0.10.3", default-features = false }
borsh09 = { package = "borsh", version = "0.9", default-features = false }
derive_more = "0.99.17"
hex-literal = "0.4.1"
ibc = { version = "0.47.0", default-features = false, features = ["serde", "borsh"] }
Expand All @@ -42,7 +43,7 @@ strum = { version = "0.25.0", default-features = false, features = ["derive"] }

lib = { path = "common/lib" }
memory = { path = "common/memory" }
sealable-trie = { path = "common/sealable-trie" }
sealable-trie = { path = "common/sealable-trie", features = ["borsh09"] }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
sealable-trie = { path = "common/sealable-trie", features = ["borsh09"] }
sealable-trie = { path = "common/sealable-trie" }

Enable this where you need it rather than globally.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually enabled it for testing so that the rust-analyzer catches it. But will remove it

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a --all-features test in CI so that should cover it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in that case i need to remove the features on imports like u mentioned

solana-trie = { path = "solana/trie" }
stdx = { path = "common/stdx" }

Expand Down
4 changes: 4 additions & 0 deletions common/lib/src/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ impl CryptoHash {
Self(buf)
}

/// Returns a shared reference to the underlying bytes array.
#[inline]
pub fn as_array(&self) -> &[u8; Self::LENGTH] { &self.0 }

/// Returns a shared reference to the hash as slice of bytes.
#[inline]
pub fn as_slice(&self) -> &[u8] { &self.0[..] }
Expand Down
2 changes: 2 additions & 0 deletions common/sealable-trie/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ edition = "2021"
[dependencies]
base64.workspace = true
borsh = { workspace = true, optional = true }
borsh09 = { workspace = true, optional = true }
derive_more.workspace = true
sha2.workspace = true
strum.workspace = true
Expand All @@ -25,3 +26,4 @@ memory = { workspace = true, features = ["test_utils"] }

[features]
borsh = ["dep:borsh", "lib/borsh"]
borsh09 = ["dep:borsh09", "lib/borsh"]
Comment on lines 26 to +29
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[features]
borsh = ["dep:borsh", "lib/borsh"]
borsh09 = ["dep:borsh09", "lib/borsh"]

This isn’t needed. lib/borsh after all is not used any longer. You might need to merge upstream I guess.

2 changes: 1 addition & 1 deletion common/sealable-trie/src/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use lib::hash::CryptoHash;
use crate::bits;
use crate::nodes::{Node, NodeRef, Reference, ValueRef};

#[cfg(feature = "borsh")]
#[cfg(any(feature = "borsh", feature = "borsh09"))]
mod serialisation;

/// A proof of a membership or non-membership of a key.
Expand Down
Loading