Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
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
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ bitvec = "1.0.1"
blake3 = "1.5.5"
blst = "0.3.14"
blstrs = "0.7.1"
borsh = { version = "1.5.5", features = ["derive", "unstable__schema"] }
borsh = { version = "1.5.5", default-features = false, features = ["derive", "unstable__schema"] }
boxcar = "0.2.12"
bs58 = { version = "0.5.1", default-features = false }
bv = "0.11.1"
Expand Down Expand Up @@ -204,10 +204,10 @@ rand = "0.8.5"
rayon = "1.10.0"
regex = "1.11"
reqwest = { version = "0.11.27", default-features = false }
serde = "1.0.226" # must match the serde_derive version, see https://github.com/serde-rs/serde/issues/2584#issuecomment-1685252251
serde = { version = "1.0.226", default-features = false } # must match the serde_derive version, see https://github.com/serde-rs/serde/issues/2584#issuecomment-1685252251
serde-big-array = "0.5.1"
serde_bytes = "0.11.15"
serde_core = "1.0.226" # must match the serde version, see https://github.com/serde-rs/serde/issues/2584#issuecomment-1685252251
serde_core = { version = "1.0.226", default-features = false } # must match the serde version, see https://github.com/serde-rs/serde/issues/2584#issuecomment-1685252251
serde_derive = "1.0.226" # must match the serde version, see https://github.com/serde-rs/serde/issues/2584#issuecomment-1685252251
serde_json = "1.0.139"
serde_with = { version = "3.12.0", default-features = false }
Expand Down
10 changes: 3 additions & 7 deletions address-lookup-table-interface/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,16 @@ bincode = [
bytemuck = ["dep:bytemuck", "solana-pubkey/bytemuck"]
dev-context-only-utils = ["bincode", "bytemuck"]
frozen-abi = ["dep:solana-frozen-abi", "dep:solana-frozen-abi-macro", "serde"]
serde = ["dep:serde", "dep:serde_derive", "solana-pubkey/serde"]
serde = ["dep:serde", "dep:serde_derive", "serde/alloc", "solana-pubkey/serde"]

[dependencies]
bincode = { workspace = true, optional = true }
bytemuck = { workspace = true, optional = true }
serde = { workspace = true, optional = true }
serde_derive = { workspace = true, optional = true }
solana-clock = { workspace = true }
solana-frozen-abi = { workspace = true, features = [
"frozen-abi",
], optional = true }
solana-frozen-abi-macro = { workspace = true, features = [
"frozen-abi",
], optional = true }
solana-frozen-abi = { workspace = true, features = ["frozen-abi"], optional = true }
solana-frozen-abi-macro = { workspace = true, features = ["frozen-abi"], optional = true }
solana-instruction = { workspace = true, features = ["std"], optional = true }
solana-instruction-error = { workspace = true, optional = true }
solana-pubkey = { workspace = true }
Expand Down
7 changes: 4 additions & 3 deletions address/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ rustdoc-args = ["--cfg=docsrs"]

[features]
atomic = ["dep:solana-atomic-u64"]
borsh = ["dep:borsh", "std"]
borsh = ["dep:borsh", "alloc"]
bytemuck = ["dep:bytemuck", "dep:bytemuck_derive"]
curve25519 = ["dep:curve25519-dalek", "error", "sha2"]
decode = ["dep:five8", "dep:five8_const", "error"]
Expand All @@ -33,7 +33,8 @@ rand = ["dep:rand", "atomic", "std"]
sanitize = ["dep:solana-sanitize"]
serde = ["dep:serde", "dep:serde_derive"]
sha2 = ["dep:solana-sha256-hasher", "error"]
std = ["decode"]
std = ["decode", "borsh?/std", "serde?/std", "alloc"]
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: Can you add a comment above this saying to remove the enabling of alloc during the next breaking release?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure we'd want this. I think std should probably enable alloc as well

Copy link
Collaborator

Choose a reason for hiding this comment

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

We're going to break up a few of these features, but it's true that it might be odd to need to enable both separately. What do you think @febo ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree, I think we should enable alloc when std is enabled – feels like it would be the expected behaviour since the std includes alloc.

alloc = []
syscalls = ["dep:solana-define-syscall", "error"]

[dependencies]
Expand Down Expand Up @@ -72,7 +73,7 @@ solana-address = { path = ".", features = [
"error",
"sanitize",
"std",
"syscalls"
"syscalls",
] }
solana-cpi = { path = "../cpi" }
solana-example-mocks = { path = "../example-mocks" }
Expand Down
12 changes: 7 additions & 5 deletions address/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@ use crate::error::ParseAddressError;
#[cfg(all(feature = "rand", not(target_os = "solana")))]
pub use crate::hasher::{AddressHasher, AddressHasherBuilder};

#[cfg(feature = "alloc")]
extern crate alloc;
#[cfg(feature = "std")]
extern crate std;
#[cfg(feature = "alloc")]
use alloc::vec::Vec;
#[cfg(feature = "dev-context-only-utils")]
use arbitrary::Arbitrary;
#[cfg(feature = "bytemuck")]
Expand All @@ -38,12 +42,10 @@ use core::{
};
#[cfg(feature = "serde")]
use serde_derive::{Deserialize, Serialize};
#[cfg(feature = "std")]
use std::vec::Vec;
#[cfg(feature = "borsh")]
use {
alloc::string::ToString,
borsh::{BorshDeserialize, BorshSchema, BorshSerialize},
std::string::ToString,
};

/// Number of bytes in an address.
Expand Down Expand Up @@ -79,7 +81,7 @@ pub const PDA_MARKER: &[u8; 21] = b"ProgramDerivedAddress";
derive(BorshSerialize, BorshDeserialize),
borsh(crate = "borsh")
)]
#[cfg_attr(all(feature = "borsh", feature = "std"), derive(BorshSchema))]
#[cfg_attr(feature = "borsh", derive(BorshSchema))]
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
#[cfg_attr(feature = "bytemuck", derive(Pod, Zeroable))]
#[cfg_attr(feature = "dev-context-only-utils", derive(Arbitrary))]
Expand Down Expand Up @@ -144,7 +146,7 @@ impl TryFrom<&[u8]> for Address {
}
}

#[cfg(feature = "std")]
#[cfg(feature = "alloc")]
impl TryFrom<Vec<u8>> for Address {
type Error = Vec<u8>;

Expand Down
3 changes: 2 additions & 1 deletion atomic-u64/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#![no_std]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
pub use implementation::AtomicU64;

#[cfg(target_pointer_width = "64")]
mod implementation {
use std::sync::atomic;
use core::sync::atomic;

pub struct AtomicU64(atomic::AtomicU64);

Expand Down
2 changes: 1 addition & 1 deletion borsh/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ edition = { workspace = true }
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
borsh = { workspace = true }
borsh = { workspace = true, features = ["std"] }

[lints]
workspace = true
4 changes: 2 additions & 2 deletions epoch-rewards/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ frozen-abi = [
"solana-hash/frozen-abi",
"std",
]
serde = ["dep:serde", "dep:serde_derive", "solana-hash/serde"]
std = []
serde = ["dep:serde", "dep:serde_derive", "serde/alloc", "solana-hash/serde"]
std = ["serde?/std"]
sysvar = ["dep:solana-sysvar-id"]

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion hard-forks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ targets = ["x86_64-unknown-linux-gnu"]

[features]
frozen-abi = ["dep:solana-frozen-abi", "dep:solana-frozen-abi-macro"]
serde = ["dep:serde", "dep:serde_derive"]
serde = ["dep:serde", "dep:serde_derive", "serde/alloc"]

[dependencies]
serde = { workspace = true, optional = true }
Expand Down
12 changes: 4 additions & 8 deletions hash/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ all-features = true
rustdoc-args = ["--cfg=docsrs"]

[features]
borsh = ["dep:borsh", "std"]
borsh = ["dep:borsh"]
bytemuck = ["dep:bytemuck", "dep:bytemuck_derive"]
default = ["std"]
frozen-abi = ["dep:solana-frozen-abi", "dep:solana-frozen-abi-macro", "std"]
serde = ["dep:serde", "dep:serde_derive"]
std = []
std = ["borsh?/std", "serde?/std"]

[dependencies]
borsh = { workspace = true, optional = true }
Expand All @@ -31,12 +31,8 @@ five8 = { workspace = true }
serde = { workspace = true, optional = true }
serde_derive = { workspace = true, optional = true }
solana-atomic-u64 = { workspace = true }
solana-frozen-abi = { workspace = true, optional = true, features = [
"frozen-abi",
] }
solana-frozen-abi-macro = { workspace = true, optional = true, features = [
"frozen-abi",
] }
solana-frozen-abi = { workspace = true, optional = true, features = ["frozen-abi"] }
solana-frozen-abi-macro = { workspace = true, optional = true, features = ["frozen-abi"] }
solana-sanitize = { workspace = true }

[dev-dependencies]
Expand Down
8 changes: 5 additions & 3 deletions hash/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ extern crate std;
use bytemuck_derive::{Pod, Zeroable};
#[cfg(feature = "serde")]
use serde_derive::{Deserialize, Serialize};
#[cfg(all(feature = "borsh", feature = "std"))]
use std::string::ToString;
#[cfg(feature = "borsh")]
extern crate alloc;
#[cfg(feature = "borsh")]
use alloc::string::ToString;
use {
core::{
fmt,
Expand All @@ -37,7 +39,7 @@ pub const MAX_BASE58_LEN: usize = 44;
derive(BorshSerialize, BorshDeserialize),
borsh(crate = "borsh")
)]
#[cfg_attr(all(feature = "borsh", feature = "std"), derive(BorshSchema))]
#[cfg_attr(feature = "borsh", derive(BorshSchema))]
#[cfg_attr(feature = "bytemuck", derive(Pod, Zeroable))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize,))]
#[derive(Clone, Copy, Default, Eq, PartialEq, Ord, PartialOrd, Hash)]
Expand Down
9 changes: 2 additions & 7 deletions instruction/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,9 @@ rustdoc-args = ["--cfg=docsrs"]
bincode = ["dep:bincode", "dep:serde"]
borsh = ["dep:borsh"]
default = ["std"]
frozen-abi = [
"dep:solana-frozen-abi",
"dep:solana-frozen-abi-macro",
"serde",
"std",
]
frozen-abi = ["dep:solana-frozen-abi", "dep:solana-frozen-abi-macro", "serde", "std"]
serde = ["dep:serde", "dep:serde_derive", "solana-pubkey/serde"]
std = []
std = ["serde?/std", "borsh?/std"]
syscalls = ["std"]

[dependencies]
Expand Down
6 changes: 5 additions & 1 deletion message/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ serde = [
"dep:serde",
"dep:serde_derive",
"dep:solana-short-vec",
"serde/alloc",
"solana-address/serde",
"solana-hash/serde",
]
Expand Down Expand Up @@ -58,7 +59,10 @@ bitflags = { workspace = true }
borsh = { workspace = true }
itertools = { workspace = true }
serde_json = { workspace = true }
solana-address-lookup-table-interface = { workspace = true, features = ["bincode", "bytemuck"] }
solana-address-lookup-table-interface = { workspace = true, features = [
"bincode",
"bytemuck",
] }
solana-example-mocks = { path = "../example-mocks" }
solana-instruction = { workspace = true, features = ["borsh"] }
solana-instruction-error = { workspace = true }
Expand Down
3 changes: 2 additions & 1 deletion msg/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ targets = ["x86_64-unknown-linux-gnu"]

[features]
default = ["std"]
std = []
alloc = []
std = ["alloc"]

[target.'cfg(target_os = "solana")'.dependencies]
solana-define-syscall = { workspace = true }
Expand Down
16 changes: 12 additions & 4 deletions msg/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
#![no_std]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#[cfg(feature = "alloc")]
extern crate alloc;
#[cfg(feature = "std")]
extern crate std;

/// We re-export the `format!` macro from `alloc` for use in the `msg!` macro
#[cfg(feature = "alloc")]
#[doc(hidden)]
pub use alloc::format;

/// Print a message to the log.
///
/// Supports simple strings as well as Rust [format strings][fs]. When passed a
Expand All @@ -11,8 +19,8 @@ extern crate std;
/// a sequence of expressions, the tokens will be passed through the
/// [`format!`] macro before being logged with `sol_log`.
///
/// [fs]: https://doc.rust-lang.org/std/fmt/
/// [`format!`]: https://doc.rust-lang.org/std/fmt/fn.format.html
/// [fs]: https://doc.rust-lang.org/alloc/fmt/
/// [`format!`]: https://doc.rust-lang.org/alloc/fmt/fn.format.html
///
/// Note that Rust's formatting machinery is relatively CPU-intensive
/// for constrained environments like the Solana VM.
Expand All @@ -29,13 +37,13 @@ extern crate std;
/// let err = "not enough signers";
/// msg!("multisig failed: {}", err);
/// ```
#[cfg(feature = "std")]
#[cfg(feature = "alloc")]
#[macro_export]
macro_rules! msg {
($msg:expr) => {
$crate::sol_log($msg)
};
($($arg:tt)*) => ($crate::sol_log(&format!($($arg)*)));
($($arg:tt)*) => ($crate::sol_log(&$crate::format!($($arg)*)));
}

#[cfg(target_os = "solana")]
Expand Down
1 change: 1 addition & 0 deletions nonce/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ dev-context-only-utils = ["serde"]
serde = [
"dep:serde",
"dep:serde_derive",
"serde/alloc",
"solana-fee-calculator/serde",
"solana-hash/serde",
"solana-pubkey/serde",
Expand Down
9 changes: 8 additions & 1 deletion pubkey/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,17 @@ rand = ["dep:rand", "solana-address/rand"]
serde = ["solana-address/serde"]
sha2 = ["solana-address/sha2"]
std = ["solana-address/std"]
alloc = ["solana-address/alloc"]

[dependencies]
rand = { workspace = true, optional = true }
solana-address = { workspace = true, features = ["atomic", "decode", "error", "sanitize", "syscalls"] }
solana-address = { workspace = true, features = [
"atomic",
"decode",
"error",
"sanitize",
"syscalls",
] }

[lints]
workspace = true
7 changes: 7 additions & 0 deletions scripts/check-no-std.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,10 @@ target="bpfel-unknown-none"
"--target=$target" \
--no-default-features \
"${no_std_crates[@]}"

# Check that all crates with features that work with no_std + alloc still work!
./cargo nightly check -Zbuild-std=alloc,core \
"--target=${target}" \
--no-default-features \
--features "decode, error, sanitize, syscalls, borsh, serde, bytemuck, alloc" \
"${no_std_crates[@]}"
10 changes: 3 additions & 7 deletions signature/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ bytemuck = ["dep:bytemuck", "dep:bytemuck_derive"]
frozen-abi = ["dep:solana-frozen-abi", "dep:solana-frozen-abi-macro", "std"]
rand = ["dep:rand"]
serde = ["dep:serde", "dep:serde_derive", "dep:serde-big-array"]
std = ["alloc"]
std = ["alloc", "serde?/std"]
verify = ["dep:ed25519-dalek"]

[dependencies]
Expand All @@ -34,12 +34,8 @@ rand = { workspace = true, optional = true }
serde = { workspace = true, optional = true }
serde-big-array = { workspace = true, optional = true }
serde_derive = { workspace = true, optional = true }
solana-frozen-abi = { workspace = true, optional = true, features = [
"frozen-abi",
] }
solana-frozen-abi-macro = { workspace = true, optional = true, features = [
"frozen-abi",
] }
solana-frozen-abi = { workspace = true, optional = true, features = ["frozen-abi"] }
solana-frozen-abi-macro = { workspace = true, optional = true, features = ["frozen-abi"] }
solana-sanitize = { workspace = true }

[dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion slot-hashes/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ edition = { workspace = true }
targets = ["x86_64-unknown-linux-gnu"]

[features]
serde = ["dep:serde", "dep:serde_derive", "solana-hash/serde"]
serde = ["dep:serde", "dep:serde_derive", "serde/alloc", "solana-hash/serde"]
sysvar = ["dep:solana-sdk-ids", "dep:solana-sysvar-id"]

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion system-interface/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ frozen-abi = [
"solana-address/frozen-abi",
"solana-address/std",
]
serde = ["dep:serde", "dep:serde_derive", "solana-address/serde"]
serde = ["dep:serde", "dep:serde_derive", "serde/alloc", "solana-address/serde"]
std = []

[dependencies]
Expand Down
Loading