Skip to content

Migrating Rust programs from v1.5 to v1.6

Jack May edited this page Mar 31, 2021 · 5 revisions

The v1.6 release line requires some minor changes to Rust program source that previously used v1.5.14 or earlier. These changes can be made with a ~v1.5.15 release as well, to prepare your program for the upgrade to v1.6.

As a reference, https://github.com/solana-labs/example-helloworld/pull/158/files makes the necessary changes to the helloworld example

Remove the explicit tokio dependency from your program crate

  1. Edit your Cargo.toml and remove the tokio = { version = "0.3", features = ["macros"]} from your [dev-dependencies]. A compatible tokio can now be imported from program-test with a use solana_program_test::tokio; statement.

The function Instruction::new() is deprecated

Instruction::new() is deprecated by Instruction::new_with_bincode() which shares the same function signature.

Most existing programs (and the built-in programs like the SystemProgram) use bincode encoded instruction data. Bincode serialization/deserialization in-program is very expensive, therefore where possible, and for new program interfaces, it is recommended not to use bincode for instruction data encoding.

Solana crate internal version pinning

The v1.5.15 and newer Rust crates pin the version of dependent Solana Rust crates to the same version, to avoid accidental version mixing and build breakage during the non-atomic publish of new release crates to crates.io.

If your program is referencing v1.5.14 or earlier, bump the Solana version to v1.5.15 to take advantage of this version pinning.