Commit fe48ae2
fix: make salt dependency optional to support no_std compilation
The salt crate enables serde/std by default, which breaks no_std
compilation for riscv64imac-unknown-none-elf target. This commit
makes salt optional and only enables it with the std feature.
Changes:
- Make salt dependency optional in Cargo.toml
- Enable salt only when std feature is active
- Add conditional compilation for salt::state::hasher usage
- In no_std environments, bucket_id_for_account and bucket_id_for_slot
panic if not overridden, preventing incorrect bucket ID calculations
- Mark ADDRESS_KEY_LEN, STORAGE_SLOT_LEN, STORAGE_KEY_LEN as std-only
The panic behavior ensures that no_std users must provide their own
bucket ID implementation, preventing silent correctness issues from
using a different hashing algorithm than the std version.
Verified:
- cargo check --target riscv64imac-unknown-none-elf --no-default-features ✓
- cargo check -p mega-evm ✓
- cargo test ✓
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 19487b6 commit fe48ae2
2 files changed
+51
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
57 | 63 | | |
58 | 64 | | |
59 | 65 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
11 | 13 | | |
| 14 | + | |
| 15 | + | |
12 | 16 | | |
13 | 17 | | |
| 18 | + | |
14 | 19 | | |
| 20 | + | |
15 | 21 | | |
| 22 | + | |
16 | 23 | | |
17 | 24 | | |
18 | 25 | | |
| |||
78 | 85 | | |
79 | 86 | | |
80 | 87 | | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
81 | 93 | | |
82 | | - | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
83 | 105 | | |
84 | 106 | | |
85 | 107 | | |
| |||
91 | 113 | | |
92 | 114 | | |
93 | 115 | | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
94 | 121 | | |
95 | | - | |
96 | | - | |
97 | | - | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
98 | 136 | | |
99 | 137 | | |
100 | 138 | | |
| |||
0 commit comments