Skip to content

Commit 06f00c1

Browse files
committed
fix feature compilations
1 parent 1e4cd1e commit 06f00c1

File tree

11 files changed

+122
-28
lines changed

11 files changed

+122
-28
lines changed

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,11 @@ pinocchio-system = { version = "0.3.0" }
122122
bs58 = "^0.5.1"
123123
litesvm = "0.7"
124124
# Anchor
125-
anchor-lang = { version = "=0.31.1" }
126-
anchor-spl = "=0.31.1"
125+
anchor-lang = { version = "0.31.1" }
126+
anchor-spl = "0.31.1"
127127

128128
# Anchor compatibility
129-
borsh = "0.10.0"
129+
borsh = { version = "0.10.4", default-features = false }
130130

131131
# Serialization
132132
serde = { version = "1.0", features = ["derive"] }
@@ -182,7 +182,7 @@ light-compressible = { path = "program-libs/compressible", version = "0.1.0" }
182182
light-ctoken-types = { path = "program-libs/ctoken-types", version = "0.1.0" }
183183
light-account-checks = { path = "program-libs/account-checks", version = "0.4.0", default-features = false }
184184
light-verifier = { path = "program-libs/verifier", version = "4.0.0" }
185-
light-zero-copy = { path = "program-libs/zero-copy", version = "0.4.0" }
185+
light-zero-copy = { path = "program-libs/zero-copy", version = "0.4.0", default-features = false }
186186
light-zero-copy-derive = { path = "program-libs/zero-copy-derive", version = "0.4.0" }
187187
photon-api = { path = "sdk-libs/photon-api", version = "0.52.0" }
188188
forester-utils = { path = "forester-utils", version = "2.0.0" }

program-libs/account-checks/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ solana = [
1616
"solana-pubkey",
1717
]
1818
pinocchio = ["dep:pinocchio"]
19-
test-only = ["dep:rand"]
19+
test-only = ["dep:rand", "std"]
2020

2121
[dependencies]
2222
solana-sysvar = { workspace = true, optional = true, features = ["bincode"] }

program-libs/batched-merkle-tree/src/errors.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub enum BatchedMerkleTreeError {
3636
#[cfg(feature = "pinocchio")]
3737
#[error("Program error {0}")]
3838
ProgramError(u64),
39-
#[cfg(not(feature = "pinocchio"))]
39+
#[cfg(all(feature = "solana", not(feature = "pinocchio")))]
4040
#[error("Program error {0}")]
4141
ProgramError(#[from] solana_program_error::ProgramError),
4242
#[error("Verifier error {0}")]
@@ -76,6 +76,7 @@ impl From<BatchedMerkleTreeError> for u32 {
7676
BatchedMerkleTreeError::BloomFilter(e) => e.into(),
7777
BatchedMerkleTreeError::VerifierErrorError(e) => e.into(),
7878
BatchedMerkleTreeError::CompressedAccountError(e) => e.into(),
79+
#[cfg(any(feature = "pinocchio", feature = "solana"))]
7980
#[allow(clippy::useless_conversion)]
8081
BatchedMerkleTreeError::ProgramError(e) => u32::try_from(u64::from(e)).unwrap(),
8182
BatchedMerkleTreeError::AccountError(e) => e.into(),

program-libs/compressed-account/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ default = ["alloc"]
1111
alloc = ["light-hasher/alloc"]
1212
std = ["alloc", "borsh/std", "dep:solana-msg", "light-zero-copy/std"]
1313
solana = ["dep:solana-pubkey", "dep:solana-program-error"]
14-
anchor = ["anchor-lang"]
14+
anchor = ["anchor-lang", "std"]
1515
pinocchio = ["dep:pinocchio"]
1616
bytemuck-des = ["bytemuck"]
1717
new-unique = ["dep:solana-pubkey"]

program-libs/compressed-account/src/instruction_data/traits.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
use core::fmt::Debug;
22

3-
#[cfg(feature = "std")]
4-
#[cfg(feature = "anchor")]
3+
#[cfg(all(feature = "std", feature = "anchor"))]
54
use anchor_lang::AnchorSerialize;
65
#[allow(unused_imports)]
7-
#[cfg(not(feature = "anchor"))]
6+
#[cfg(not(all(feature = "std", feature = "anchor")))]
87
use borsh::BorshSerialize as AnchorSerialize;
98
use light_program_profiler::profile;
109
use tinyvec::ArrayVec;

program-libs/compressible/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ edition = "2021"
66
[features]
77
default = ["pinocchio", "solana"]
88
solana = ["dep:solana-program-error", "light-compressed-account/solana", "solana-sysvar"]
9-
anchor = ["anchor-lang", "light-compressed-account/anchor"]
9+
anchor = ["anchor-lang", "light-compressed-account/anchor", "light-compressed-account/std"]
1010
pinocchio = ["light-compressed-account/pinocchio"]
1111
profile-program = []
1212
profile-heap = ["dep:light-heap"]

program-libs/hasher/tests/hash_to_field_size.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
#![cfg(feature = "std")]
2-
use std::vec::Vec;
32

43
#[cfg(feature = "poseidon")]
54
use ark_ff::PrimeField;
65
use borsh::{BorshDeserialize, BorshSerialize};
6+
#[cfg(feature = "solana")]
7+
use light_hasher::hash_to_field_size::hashv_to_bn254_field_size_be;
78
#[cfg(all(not(target_os = "solana"), feature = "poseidon"))]
89
use light_hasher::hash_to_field_size::is_smaller_than_bn254_field_size_be;
910
use light_hasher::{
1011
bigint::bigint_to_be_bytes_array,
11-
hash_to_field_size::{
12-
hash_to_bn254_field_size_be, hashv_to_bn254_field_size_be, HashToFieldSize,
13-
},
12+
hash_to_field_size::{hash_to_bn254_field_size_be, HashToFieldSize},
1413
};
1514
use num_bigint::{BigUint, ToBigUint};
1615

program-libs/zero-copy/tests/borsh.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,21 +285,20 @@ pub struct ArrayStruct {
285285
}
286286

287287
#[test]
288-
fn test_array_struct() -> Result<(), Box<dyn std::error::Error>> {
288+
fn test_array_struct() {
289289
let array_struct = ArrayStruct {
290290
a: [1u8; 32],
291291
b: [2u8; 64],
292292
c: [3u8; 32],
293293
};
294-
let bytes = array_struct.try_to_vec()?;
294+
let bytes = array_struct.try_to_vec().unwrap();
295295

296296
let (zero_copy, remaining) = ArrayStruct::zero_copy_at(&bytes).unwrap();
297297
assert_eq!(zero_copy.a, [1u8; 32]);
298298
assert_eq!(zero_copy.b, [2u8; 64]);
299299
assert_eq!(zero_copy.c, [3u8; 32]);
300300
assert_eq!(zero_copy, array_struct);
301301
assert_eq!(remaining, &[]);
302-
Ok(())
303302
}
304303

305304
#[repr(C)]

scripts/lint.sh

Lines changed: 103 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,106 @@ npx nx run-many --target=lint --all
77
cargo +nightly fmt --all -- --check
88
cargo clippy --workspace --all-features --all-targets -- -D warnings
99

10-
# Check no_std compatibility for light-zero-copy crate
11-
echo "Checking no_std compatibility for light-zero-copy..."
12-
cargo check -p light-zero-copy --no-default-features
13-
cargo check -p light-compressed-account --no-default-features
14-
cargo check -p light-sdk-types --no-default-features
15-
cargo check -p light-sdk-pinocchio --no-default-features
10+
echo "Testing feature combinations..."
11+
12+
# Test no-default-features for all library crates
13+
echo "Testing all library crates with --no-default-features..."
14+
NO_DEFAULT_CRATES=(
15+
"light-account-checks"
16+
"light-batched-merkle-tree"
17+
"light-bloom-filter"
18+
"light-compressed-account"
19+
"light-compressible"
20+
"light-concurrent-merkle-tree"
21+
"light-ctoken-types"
22+
"light-hash-set"
23+
"light-hasher"
24+
"light-indexed-merkle-tree"
25+
"light-macros"
26+
"light-merkle-tree-metadata"
27+
"light-verifier"
28+
"light-zero-copy"
29+
"light-heap"
30+
"light-array-map"
31+
"light-indexed-array"
32+
"aligned-sized"
33+
"light-sdk-types"
34+
"light-sdk-pinocchio"
35+
"light-sdk-macros"
36+
"light-compressed-token-sdk"
37+
"light-compressed-token-types"
38+
"light-sdk"
39+
)
40+
41+
for crate in "${NO_DEFAULT_CRATES[@]}"; do
42+
echo "Checking $crate with --no-default-features..."
43+
cargo check -p "$crate" --no-default-features
44+
done
45+
46+
# Test pinocchio feature for all crates that have it
47+
PINOCCHIO_CRATES=(
48+
"light-hasher"
49+
"light-indexed-merkle-tree"
50+
"light-zero-copy"
51+
"light-bloom-filter"
52+
"light-compressed-account"
53+
"light-merkle-tree-metadata"
54+
"light-macros"
55+
"light-batched-merkle-tree"
56+
"light-concurrent-merkle-tree"
57+
"light-verifier"
58+
"light-account-checks"
59+
"light-compressible"
60+
)
61+
62+
for crate in "${PINOCCHIO_CRATES[@]}"; do
63+
echo "Checking $crate with pinocchio feature..."
64+
cargo check -p "$crate" --features pinocchio
65+
done
66+
67+
# Test solana feature for all crates that have it
68+
SOLANA_CRATES=(
69+
"light-hasher"
70+
"light-indexed-merkle-tree"
71+
"light-zero-copy"
72+
"light-bloom-filter"
73+
"light-compressed-account"
74+
"light-hash-set"
75+
"light-merkle-tree-metadata"
76+
"light-ctoken-types"
77+
"light-macros"
78+
"light-batched-merkle-tree"
79+
"light-concurrent-merkle-tree"
80+
"light-verifier"
81+
"light-account-checks"
82+
"light-compressible"
83+
)
84+
85+
for crate in "${SOLANA_CRATES[@]}"; do
86+
echo "Checking $crate with solana feature..."
87+
cargo check -p "$crate" --features solana
88+
done
89+
90+
# Test anchor feature for all crates that have it
91+
ANCHOR_CRATES=(
92+
"light-indexed-merkle-tree"
93+
"light-compressed-account"
94+
"light-merkle-tree-metadata"
95+
"light-ctoken-types"
96+
"light-verifier"
97+
"light-compressible"
98+
"light-sdk-types"
99+
"light-sdk"
100+
"light-compressed-token-sdk"
101+
"light-compressed-token-types"
102+
)
103+
104+
for crate in "${ANCHOR_CRATES[@]}"; do
105+
echo "Checking $crate with anchor feature..."
106+
cargo check -p "$crate" --features anchor
107+
done
108+
109+
for crate in "${NO_DEFAULT_CRATES[@]}"; do
110+
echo "Checking $crate with --no-default-features..."
111+
cargo test -p "$crate" --no-run
112+
done

sdk-libs/compressed-token-sdk/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ light-program-profiler = { workspace = true }
4747
anchor-lang = { workspace = true, optional = true }
4848

4949
[dev-dependencies]
50-
light-account-checks = { workspace = true, features = ["test-only", "pinocchio"] }
50+
light-account-checks = { workspace = true, features = ["test-only", "pinocchio", "std"] }
5151
anchor-lang = { workspace = true }
5252
light-compressed-token = { workspace = true }
5353
pinocchio = { workspace = true }

0 commit comments

Comments
 (0)