@@ -8,6 +8,14 @@ validator.
88
99## Upgrading from v2 to v3
1010
11+ The easiest way to upgrade to v3 is:
12+
13+ * upgrade to the latest v2 crates
14+ * fix all deprecation warnings
15+ * (optional) switch to using SPL interface crates v1
16+ * upgrade to v3-compatible crates
17+ * (optional) upgrade SPL interface crates to v2
18+
1119### solana-sdk
1220
1321The following modules have been removed, please use their component crates
@@ -76,6 +84,81 @@ directly:
7684* [ ` system_program ` ] ( https://docs.rs/solana-program/latest/solana_program/system_program ) -> [ ` solana_system_interface::program ` ] ( https://docs.rs/solana-system-interface/latest/solana_system_interface/program )
7785* [ ` vote ` ] ( https://docs.rs/solana-program/latest/solana_program/vote ) -> [ ` solana_vote_interface ` ] ( https://docs.rs/solana-vote-interface/latest/solana_vote_interface )
7886
87+ ### Breaking Changes
88+
89+ #### Address / Pubkey
90+
91+ SDK v3 introduces the ` Address ` type, a better named and more flexible version
92+ of ` Pubkey ` . ` Pubkey ` is a type alias of ` Address ` , so if you see errors related
93+ to ` Address ` vs ` Pubkey ` in your build, it simply means that one of your
94+ dependencies hasn't been upgraded to v3.
95+
96+ #### AccountInfo
97+
98+ Removed ` rent_epoch ` field, now called ` _unused ` . This field can be completely
99+ ignored. The final parameter in ` AccountInfo::new ` was removed.
100+
101+ #### Hash
102+
103+ The inner bytes were made private, so use ` Hash::as_bytes() ` to access them.
104+
105+ #### Genesis
106+
107+ Moved ` ClusterType ` to ` solana-cluster-type ` .
108+
109+ #### Keypair
110+
111+ Use ` Keypair::try_from ` instead of ` Keypair::from_bytes ` .
112+
113+ #### Instruction-Error / Program-Error
114+
115+ Changed ` BorshIoError(String) ` -> ` BorshIoError ` , so no more string parameter
116+ exists in either ` InstructionError ` or ` ProgramError ` .
117+
118+ #### Program Memory
119+
120+ Marked all onchain memory operations usage as unsafe, so all usages of memory
121+ operations need to be in an ` unsafe ` block.
122+
123+ #### Sysvar
124+
125+ If you're using ` Sysvar::from_account_info ` , you'll need to also import
126+ ` solana_sysvar::SysvarSerialize ` .
127+
128+ #### Stake
129+
130+ ` StakeHistory ` now lives in ` solana_stake_interface ` instead of ` solana_sysvar ` .
131+
132+ #### Vote Interface
133+
134+ * ` VoteState ` -> ` VoteStateV3 `
135+ * ` convert_to_current ` -> ` convert_to_v3 `
136+ * ` new_current ` -> ` new_v3 `
137+
138+ ### SPL Dependencies
139+
140+ SPL libraries have been broken up between an interface and program crate for
141+ lighter dependency management and to allow LTO on builds.
142+
143+ When upgrading to SDK v3 crates, replace the following with v2 of the corresponding
144+ interface crate:
145+
146+ * ` spl-token ` -> ` spl-token-interface `
147+ * ` spl-token-2022 ` -> ` spl-token-2022-interface `
148+ * ` spl-associated-token-account ` -> ` spl-associated-token-account-interface `
149+ * ` spl-memo ` -> ` spl-memo-interface `
150+
151+ For example, if you're using ` spl-token ` v8, you should switch to
152+ ` spl-token-interface ` v2 when upgrading to SDK v3. The state, instruction, and
153+ error modules mimic the program crates, so no other changes should be required.
154+
155+ Program crates, like ` spl-token ` , contain a ` cdylib ` target, so the Rust
156+ compiler cannot run LTO. Interface crates only declare a ` lib ` target, and
157+ contain fewer dependencies. You can run LTO with ` cargo build-sbf --lto ` .
158+
159+ NOTE: Results with ` --lto ` are mixed, so be sure to profile your program's size
160+ and CU usage with and without the flag.
161+
79162## Building
80163
81164### ** 1. Install rustc, cargo and rustfmt.**
0 commit comments