Exposes C-ABI bindings for drift program.
Goals:
- Enable building SDKs that reuse program logic.
- Separate rust SDK from program/solana runtime dependencies. Allows rust SDK to freely update to latest solana-* crates with bug fixes, improvements, etc.
Download latest release libs, unzip and link/copy to /usr/lib (linux) or /usr/local/lib (mac)
rustup install 1.76.0-x86_64-apple-darwin # M1 mac
rustup install 1.76.0-x86_64-unknown-linux-gnu # linux
cargo build --release
ln -sf ./target/release/libdrift_ffi_sys.dylib /usr/local/lib # mac
ln -sf ./target/release/libdrift_ffi_sys.so /usr/lib #linux-
this crate must be built with rust <= 1.76.0 to provide compatibility with onchain data layouts (later rust versions have breaking changes 128-bit integer C-abi compatibility)
-
for rust users this crate is intended to be linked via compiler flags (not Cargo dependency) as it compiles to a (platform dependent) dynamic lib (
.so/.dylib/.dll) -
can ignore most of the warnings for FFI safety. The main issue are types containing
u128/i128s which are handled by a customcompat::u128/i128type that forces correct alignment where required.
CI job does this automatically but occasionally fails due to breaking changes.
- checkout / pull master
- update
tag = "v2.140.0"to the latest version inCargo.toml
drift-program = { package = "drift", git = "https://github.com/drift-labs/protocol-v2.git", tag = "v2.140.0", features = [
"mainnet-beta", "drift-rs"
] }-
update Cargo.toml to new version:
version = "vX.Y.Z" -
cargo checkand fix any compile issues -
git commit,
git tag -v vX.Y.Zand push to release the new version
