diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1f0ac4e0..06e99a28 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -2,11 +2,11 @@ name: ci on: push: - branches: [ master ] + branches: [master] tags: - - 'v*' + - "v*" pull_request: - branches: [ master ] + branches: [master] concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} @@ -20,18 +20,23 @@ jobs: - uses: actions/checkout@v4 with: submodules: recursive + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + toolchain: 1.85.0 - name: Install cargo-audit from crates.io uses: baptiste0928/cargo-install@v3 with: crate: cargo-audit - version: "0.21.1" + version: "0.22.1" - run: | cargo audit \ --ignore RUSTSEC-2022-0093 \ --ignore RUSTSEC-2024-0344 \ --ignore RUSTSEC-2024-0421 \ --ignore RUSTSEC-2025-0022 \ - --ignore RUSTSEC-2025-0055 # waiting for solana upgrade + --ignore RUSTSEC-2025-0055 \ + --ignore RUSTSEC-2026-0007 \ + --ignore RUSTSEC-2026-0009 code_gen: # cargo b && ./target/debug/jito-shank-cli && yarn generate-clients && cargo b @@ -41,27 +46,27 @@ jobs: - uses: actions/checkout@v4 with: submodules: recursive - + - uses: actions-rust-lang/setup-rust-toolchain@v1 with: components: rustfmt, clippy toolchain: 1.84.1 - name: Install system dependencies run: sudo apt-get update && sudo apt-get install -y libudev-dev - + - name: Set Node.js 22.x uses: actions/setup-node@v3 with: - node-version: '22.x' - + node-version: "22.x" + - name: Generate all code run: make generate-code - + - name: Verify no file changes uses: tj-actions/verify-changed-files@v20 with: fail-if-changed: true - fail-message: 'Unexpected changes in generated files. Please run `make generate-code` locally to regenerate the files.' + fail-message: "Unexpected changes in generated files. Please run `make generate-code` locally to regenerate the files." lint: name: lint diff --git a/.github/workflows/publish-crate.yaml b/.github/workflows/publish-crate.yaml index 929bc27c..968a7242 100644 --- a/.github/workflows/publish-crate.yaml +++ b/.github/workflows/publish-crate.yaml @@ -6,11 +6,9 @@ on: package_path: description: Which crate to publish required: true - default: 'account_traits_derive' + default: "clients/rust/common" type: choice options: - - account_traits_derive - - bytemuck - clients/rust/common - clients/rust/restaking_client - clients/rust/vault_client @@ -151,7 +149,7 @@ jobs: run: | # Get current version before update OLD_VERSION=$(grep -m1 'version =' Cargo.toml | cut -d '"' -f2) - + if [ "${{ inputs.dry_run }}" == "true" ]; then # For dry-run mode, don't use the -x flag (dry-run is default) cargo release ${{ inputs.level }} --no-confirm --no-push @@ -159,10 +157,10 @@ jobs: # For actual execution, use the -x flag cargo release ${{ inputs.level }} --no-confirm -x fi - + # Get new version after update NEW_VERSION=$(grep -m1 'version =' Cargo.toml | cut -d '"' -f2) - + # Set outputs for the release step echo "old_version=${OLD_VERSION}" >> $GITHUB_OUTPUT echo "new_version=${NEW_VERSION}" >> $GITHUB_OUTPUT @@ -182,4 +180,4 @@ jobs: with: tag: ${{ steps.publish.outputs.new_git_tag }} name: "${{ steps.extract_name.outputs.crate_name }} v${{ steps.publish.outputs.new_version }}" - body: ${{ steps.changelog.outputs.changelog }} \ No newline at end of file + body: ${{ steps.changelog.outputs.changelog }} diff --git a/.github/workflows/publish-crates.yaml b/.github/workflows/publish-crates.yaml index 3dfb6820..5f8f815a 100644 --- a/.github/workflows/publish-crates.yaml +++ b/.github/workflows/publish-crates.yaml @@ -4,9 +4,9 @@ on: workflow_dispatch: inputs: package_path: - description: 'Comma-separated list of crates to publish. Example: core,restaking_core,cli' + description: "Comma-separated list of crates to publish. Example: core,restaking_core,cli" required: true - default: 'account_traits_derive,bytemuck,clients/rust/common,clients/rust/restaking_client,clients/rust/vault_client,core,restaking_sdk,restaking_core,restaking_program,vault_sdk,vault_core,vault_program' + default: "clients/rust/common,clients/rust/restaking_client,clients/rust/vault_client,core,restaking_sdk,restaking_core,restaking_program,vault_sdk,vault_core,vault_program" type: string level: description: Version increment level for selected crates @@ -18,7 +18,7 @@ on: - minor - major tag_name: - description: 'Custom tag name for release. Example: v1.2.3 or release-2024-01' + description: "Custom tag name for release. Example: v1.2.3 or release-2024-01" required: true type: string dry_run: @@ -46,8 +46,6 @@ jobs: run: | # All available crates in dependency order ALL_CRATES=( - "account_traits_derive" - "bytemuck" "clients/rust/common" "clients/rust/restaking_client" "clients/rust/vault_client" @@ -59,7 +57,7 @@ jobs: "vault_core" "vault_program" ) - + # Check if input contains commas (multiple crates) or is "all" if [[ "${{ inputs.package_path }}" == "all" ]]; then # Publish all crates @@ -70,7 +68,7 @@ jobs: # Multiple crates - parse comma-separated list IFS=',' read -ra SELECTED_ARRAY <<< "${{ inputs.package_path }}" CRATES_TO_PUBLISH=() - + # Validate and order selected crates according to dependency order for crate in "${ALL_CRATES[@]}"; do for selected in "${SELECTED_ARRAY[@]}"; do @@ -82,7 +80,7 @@ jobs: fi done done - + echo "๐Ÿ“ฆ Publishing MULTIPLE crates: ${{ inputs.package_path }}" IS_SINGLE="false" else @@ -91,15 +89,15 @@ jobs: echo "๐Ÿ“ฆ Publishing SINGLE crate: ${{ inputs.package_path }}" IS_SINGLE="true" fi - + # Convert to space-separated string for output CRATES_STRING=$(IFS=' '; echo "${CRATES_TO_PUBLISH[*]}") COUNT=${#CRATES_TO_PUBLISH[@]} - + echo "crates_to_publish=$CRATES_STRING" >> $GITHUB_OUTPUT echo "crate_count=$COUNT" >> $GITHUB_OUTPUT echo "is_single_crate=$IS_SINGLE" >> $GITHUB_OUTPUT - + echo "Will publish $COUNT crates: $CRATES_STRING" echo "Is single crate: $IS_SINGLE" @@ -208,52 +206,52 @@ jobs: run: | # Convert space-separated string back to array read -ra CRATES_TO_PUBLISH <<< "${{ needs.determine_crates.outputs.crates_to_publish }}" - + PUBLISHED_CRATES="" - + # Determine the version level to use LEVEL="${{ inputs.level }}" - + for crate_path in "${CRATES_TO_PUBLISH[@]}"; do echo "=========================================" echo "Publishing $crate_path..." echo "=========================================" cd "$GITHUB_WORKSPACE/$crate_path" - + # Get versions OLD_VERSION=$(grep -m1 'version =' Cargo.toml | cut -d '"' -f2) CRATE_NAME=$(basename "$crate_path") - + echo "Current version: $OLD_VERSION" - + if [ "${{ inputs.dry_run }}" == "true" ]; then echo "๐Ÿงช DRY RUN: Would publish $CRATE_NAME $LEVEL" cargo release $LEVEL --no-confirm --no-push else echo "๐Ÿš€ Publishing $CRATE_NAME $LEVEL" cargo release $LEVEL --no-confirm -x - + # Wait a bit between publishes to avoid rate limits (only for multiple crates) if [ "${{ needs.determine_crates.outputs.is_single_crate }}" == "false" ]; then echo "โณ Waiting 10 seconds before next publish..." sleep 10 fi fi - + NEW_VERSION=$(grep -m1 'version =' Cargo.toml | cut -d '"' -f2) echo "New version: $NEW_VERSION" - + # Track published crates for summary PUBLISHED_CRATES="${PUBLISHED_CRATES}- **${CRATE_NAME}**: ${OLD_VERSION} โ†’ ${NEW_VERSION}\n" - + echo "โœ… Completed $CRATE_NAME" cd "$GITHUB_WORKSPACE" done - + echo "published_crates<> $GITHUB_OUTPUT echo -e "$PUBLISHED_CRATES" >> $GITHUB_OUTPUT echo "EOF" >> $GITHUB_OUTPUT - + echo "=========================================" echo "๐ŸŽ‰ Publishing completed!" echo "=========================================" @@ -276,12 +274,12 @@ jobs: run: | # Convert space-separated string back to array read -ra CRATES_TO_PUBLISH <<< "${{ needs.determine_crates.outputs.crates_to_publish }}" - + # Determine release info based on what was published TIMESTAMP=$(date +%Y%m%d-%H%M%S) CRATE_COUNT=${{ needs.determine_crates.outputs.crate_count }} TAG_NAME=${{ github.event.inputs.tag_name }} - + if [ "${{ needs.determine_crates.outputs.is_single_crate }}" == "true" ]; then # Single crate release CRATE_PATH="${CRATES_TO_PUBLISH[0]}" @@ -294,9 +292,9 @@ jobs: # Multiple crates release RELEASE_TITLE="Jito Restaking Release - $(date +%Y-%m-%d)" fi - + echo "Creating combined release: $RELEASE_TITLE" - + # Build release notes RELEASE_NOTES="## $RELEASE_TITLE @@ -307,16 +305,16 @@ jobs: ### ๐Ÿ“ What's Changed Recent changes across all published crates:" - + # Generate combined changelog COMBINED_CHANGELOG="" for crate_path in "${CRATES_TO_PUBLISH[@]}"; do CRATE_NAME=$(basename "$crate_path") echo "Generating changelog for $CRATE_NAME..." - + # Get recent commits for this crate CRATE_CHANGELOG=$(git log --pretty=format:'- %s' --no-merges $(git describe --tags --abbrev=0 2>/dev/null || echo "")..HEAD -- "$crate_path" | head -5) - + if [ -n "$CRATE_CHANGELOG" ]; then COMBINED_CHANGELOG="$COMBINED_CHANGELOG @@ -324,22 +322,22 @@ jobs: $CRATE_CHANGELOG" fi done - + if [ -z "$COMBINED_CHANGELOG" ]; then COMBINED_CHANGELOG=" - Published new versions of selected crates" fi - + RELEASE_NOTES="$RELEASE_NOTES$COMBINED_CHANGELOG **Full Changelog**: https://github.com/${{ github.repository }}/commits/$TAG_NAME" - + # Create the combined GitHub release gh release create "$TAG_NAME" \ --title "$RELEASE_TITLE" \ --notes "$RELEASE_NOTES" \ --latest=true - + echo "โœ… Created combined release: $TAG_NAME" env: GH_TOKEN: ${{ secrets.JITO_TEAM_PAT }} @@ -360,18 +358,18 @@ jobs: echo "- **Dry run**: ${{ inputs.dry_run }}" >> $GITHUB_STEP_SUMMARY echo "- **Version level**: ${{ inputs.level }}" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY - + if [ "${{ inputs.dry_run }}" == "true" ]; then echo "โš ๏ธ **This was a dry run - no actual publishing occurred**" >> $GITHUB_STEP_SUMMARY else echo "โœ… **Publishing completed successfully!**" >> $GITHUB_STEP_SUMMARY - + if [ "${{ inputs.create_release }}" == "true" ]; then echo "๐Ÿท๏ธ **Combined GitHub release created**" >> $GITHUB_STEP_SUMMARY fi fi - + echo "" >> $GITHUB_STEP_SUMMARY echo "### ๐Ÿ“‹ Published Crates" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY - echo "${{ needs.publish.outputs.published_crates }}" >> $GITHUB_STEP_SUMMARY \ No newline at end of file + echo "${{ needs.publish.outputs.published_crates }}" >> $GITHUB_STEP_SUMMARY diff --git a/Cargo.lock b/Cargo.lock index 09445173..d179ad30 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2493,6 +2493,17 @@ checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" [[package]] name = "jito-account-traits-derive" version = "0.0.5" +source = "git+https://github.com/jito-foundation/jito-account-traits-derive.git?tag=v0.0.5#3d9e124f033965a29c56fe31c9d1ae618211efe7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.98", +] + +[[package]] +name = "jito-account-traits-derive" +version = "0.0.5" +source = "git+https://github.com/jito-foundation/jito-account-traits-derive.git#3d9e124f033965a29c56fe31c9d1ae618211efe7" dependencies = [ "proc-macro2", "quote", @@ -2502,10 +2513,11 @@ dependencies = [ [[package]] name = "jito-bytemuck" version = "0.0.5" +source = "git+https://github.com/jito-foundation/jito-bytemuck.git?tag=v0.0.5#c89e33ad06cb7936962c77ed91ccd7def4907fd3" dependencies = [ "borsh 0.10.4", "bytemuck", - "jito-account-traits-derive", + "jito-account-traits-derive 0.0.5 (git+https://github.com/jito-foundation/jito-account-traits-derive.git)", "solana-program", ] @@ -2680,7 +2692,7 @@ dependencies = [ "dotenvy", "env_logger 0.10.2", "futures", - "jito-account-traits-derive", + "jito-account-traits-derive 0.0.5 (git+https://github.com/jito-foundation/jito-account-traits-derive.git?tag=v0.0.5)", "jito-bytemuck", "jito-jsm-core", "jito-restaking-client", diff --git a/Cargo.toml b/Cargo.toml index 8b4e71e8..ca52e937 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,5 @@ [workspace] members = [ - "account_traits_derive", - "bytemuck", "clients/rust/common", "clients/rust/restaking_client", "clients/rust/vault_client", @@ -43,8 +41,8 @@ dotenvy = "0.15.7" env_logger = "0.10.2" envfile = "0.2.1" futures = "0.3.31" -jito-account-traits-derive = { path = "account_traits_derive", version = "=0.0.5" } -jito-bytemuck = { path = "bytemuck", version = "=0.0.5" } +jito-account-traits-derive = { git = "https://github.com/jito-foundation/jito-account-traits-derive.git", tag = "v0.0.5" } +jito-bytemuck = { git = "https://github.com/jito-foundation/jito-bytemuck.git", tag = "v0.0.5" } jito-jsm-core = { path = "core", version = "=0.0.5" } jito-restaking-client = { path = "clients/rust/restaking_client", version = "=0.0.5" } jito-restaking-client-common = { path = "clients/rust/common", version = "=0.0.5" } diff --git a/account_traits_derive/Cargo.toml b/account_traits_derive/Cargo.toml deleted file mode 100644 index 37d8505f..00000000 --- a/account_traits_derive/Cargo.toml +++ /dev/null @@ -1,18 +0,0 @@ -[package] -name = "jito-account-traits-derive" -description = "Jito account trait derive" -version = "0.0.5" -authors = { workspace = true } -repository = { workspace = true } -homepage = { workspace = true } -license = { workspace = true } -edition = { workspace = true } -readme = { workspace = true } - -[lib] -proc-macro = true - -[dependencies] -proc-macro2 = { workspace = true } -quote = { workspace = true } -syn = { workspace = true } diff --git a/account_traits_derive/src/lib.rs b/account_traits_derive/src/lib.rs deleted file mode 100644 index 33742c80..00000000 --- a/account_traits_derive/src/lib.rs +++ /dev/null @@ -1,15 +0,0 @@ -use proc_macro::TokenStream; -use quote::quote; -use syn::{parse_macro_input, DeriveInput}; - -#[proc_macro_derive(AccountDeserialize)] -pub fn derive_account_deserialize(input: TokenStream) -> TokenStream { - let input = parse_macro_input!(input as DeriveInput); - let name = &input.ident; - - let expanded = quote! { - impl AccountDeserialize for #name {} - }; - - TokenStream::from(expanded) -} diff --git a/bytemuck/Cargo.toml b/bytemuck/Cargo.toml deleted file mode 100644 index 9f19c697..00000000 --- a/bytemuck/Cargo.toml +++ /dev/null @@ -1,16 +0,0 @@ -[package] -name = "jito-bytemuck" -description = "Jito bytemuck library" -version = "0.0.5" -authors = { workspace = true } -repository = { workspace = true } -homepage = { workspace = true } -license = { workspace = true } -edition = { workspace = true } -readme = { workspace = true } - -[dependencies] -borsh = { workspace = true } -bytemuck = { workspace = true } -jito-account-traits-derive = { workspace = true } -solana-program = { workspace = true } diff --git a/bytemuck/src/lib.rs b/bytemuck/src/lib.rs deleted file mode 100644 index 937e29e4..00000000 --- a/bytemuck/src/lib.rs +++ /dev/null @@ -1,55 +0,0 @@ -//! Trait that can be used when working with Solana structs that are used as accounts. - -pub mod types; - -use bytemuck::Pod; -pub use jito_account_traits_derive::AccountDeserialize; -use solana_program::{msg, program_error::ProgramError}; - -pub trait Discriminator { - const DISCRIMINATOR: u8; -} - -pub trait AccountDeserialize: Sized + Pod + Discriminator { - /// Deserialize the account data into a struct. - /// It assumes the first byte is the discriminator and the next seven bytes are reserved. - /// The rest of the data is deserialized into the struct. - /// - /// # Arguments - /// * `data` - The account data to deserialize - /// - /// # Returns - /// * `Result<&Self, ProgramError>` - The deserialized struct as a reference or an error - fn try_from_slice_unchecked(data: &[u8]) -> Result<&Self, ProgramError> { - if data.first() != Some(&Self::DISCRIMINATOR) { - msg!( - "Discriminator is invalid; expected {}, got {}", - Self::DISCRIMINATOR, - data.first().unwrap() - ); - return Err(ProgramError::InvalidAccountData); - } - bytemuck::try_from_bytes(&data[8..]).map_err(|_| ProgramError::InvalidAccountData) - } - - /// Deserialize the account data into a mutable struct. - /// It assumes the first byte is the discriminator and the next seven bytes are reserved. - /// The rest of the data is deserialized into the struct. - /// - /// # Arguments - /// * `data` - The account data to deserialize - /// - /// # Returns - /// * `Result<&mut Self, ProgramError>` - The deserialized struct as a reference or an error - fn try_from_slice_unchecked_mut(data: &mut [u8]) -> Result<&mut Self, ProgramError> { - if data.first() != Some(&Self::DISCRIMINATOR) { - msg!( - "Discriminator is invalid; expected {}, got {}", - Self::DISCRIMINATOR, - data.first().unwrap() - ); - return Err(ProgramError::InvalidAccountData); - } - bytemuck::try_from_bytes_mut(&mut data[8..]).map_err(|_| ProgramError::InvalidAccountData) - } -} diff --git a/bytemuck/src/types.rs b/bytemuck/src/types.rs deleted file mode 100644 index e38a8309..00000000 --- a/bytemuck/src/types.rs +++ /dev/null @@ -1,284 +0,0 @@ -use std::fmt::{Debug, Formatter}; - -// https://github.com/solana-labs/solana-program-library/tree/master/libraries/pod -use bytemuck::{Pod, Zeroable}; - -/// Simple macro for implementing conversion functions between Pod* ints and -/// standard ints. -/// -/// The standard int types can cause alignment issues when placed in a `Pod`, -/// so these replacements are usable in all `Pod`s. -#[macro_export] -macro_rules! impl_int_conversion { - ($P:ty, $I:ty) => { - impl From<$I> for $P { - fn from(n: $I) -> Self { - Self(n.to_le_bytes()) - } - } - impl From<&$I> for $P { - fn from(n: &$I) -> Self { - Self(n.to_le_bytes()) - } - } - impl From<$P> for $I { - fn from(pod: $P) -> Self { - Self::from_le_bytes(pod.0) - } - } - impl From<&$P> for $I { - fn from(pod: &$P) -> Self { - Self::from_le_bytes(pod.0) - } - } - }; -} - -#[derive(Clone, Copy, Default, PartialEq, Pod, Zeroable, Eq)] -#[repr(transparent)] -pub struct PodU16([u8; 2]); -impl_int_conversion!(PodU16, u16); - -impl Debug for PodU16 { - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - let v: u16 = u16::from(self); - f.debug_tuple("PodU16").field(&v).finish() - } -} - -#[derive(Clone, Copy, Default, PartialEq, Pod, Zeroable, Eq)] -#[repr(transparent)] -pub struct PodU32([u8; 4]); -impl_int_conversion!(PodU32, u32); - -impl Debug for PodU32 { - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - let v: u32 = u32::from(self); - f.debug_tuple("PodU32").field(&v).finish() - } -} - -#[derive(Clone, Copy, Default, PartialEq, Pod, Zeroable, Eq)] -#[repr(transparent)] -pub struct PodU64([u8; 8]); -impl_int_conversion!(PodU64, u64); - -impl Debug for PodU64 { - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - let v: u64 = u64::from(self); - f.debug_tuple("PodU64").field(&v).finish() - } -} - -#[derive(Clone, Copy, Default, PartialEq, Pod, Zeroable, Eq)] -#[repr(transparent)] -pub struct PodU128([u8; 16]); -impl_int_conversion!(PodU128, u128); - -impl Debug for PodU128 { - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - let v: u128 = u128::from(self); - f.debug_tuple("PodU128").field(&v).finish() - } -} - -/// The standard `bool` is not a `Pod`, define a replacement that is -#[derive(Clone, Copy, Default, PartialEq, Eq, Pod, Zeroable)] -#[repr(transparent)] -pub struct PodBool(pub u8); -impl PodBool { - pub const fn from_bool(b: bool) -> Self { - Self(if b { 1 } else { 0 }) - } -} - -impl From for PodBool { - fn from(b: bool) -> Self { - Self::from_bool(b) - } -} - -impl From<&bool> for PodBool { - fn from(b: &bool) -> Self { - Self(if *b { 1 } else { 0 }) - } -} - -impl From<&PodBool> for bool { - fn from(b: &PodBool) -> Self { - b.0 != 0 - } -} - -impl From for bool { - fn from(b: PodBool) -> Self { - b.0 != 0 - } -} - -impl Debug for PodBool { - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - let v: bool = bool::from(self); - f.debug_tuple("PodBool").field(&v).finish() - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_pod_u16() { - // Test zero - let zero = PodU16::default(); - assert_eq!(u16::from(zero), 0); - - // Test conversion from u16 - let n: u16 = 12345; - let pod = PodU16::from(n); - assert_eq!(u16::from(pod), n); - - // Test reference conversion - let pod_from_ref = PodU16::from(&n); - assert_eq!(u16::from(pod_from_ref), n); - - // Test max value - let max = PodU16::from(u16::MAX); - assert_eq!(u16::from(max), u16::MAX); - } - - #[test] - fn test_pod_u32() { - // Test zero - let zero = PodU32::default(); - assert_eq!(u32::from(zero), 0); - - // Test conversion from u32 - let n: u32 = 305_419_896; - let pod = PodU32::from(n); - assert_eq!(u32::from(pod), n); - - // Test reference conversion - let pod_from_ref = PodU32::from(&n); - assert_eq!(u32::from(pod_from_ref), n); - - // Test max value - let max = PodU32::from(u32::MAX); - assert_eq!(u32::from(max), u32::MAX); - } - - #[test] - fn test_pod_u64() { - // Test zero - let zero = PodU64::default(); - assert_eq!(u64::from(zero), 0); - - // Test conversion from u64 - let n: u64 = 1_311_768_467_294_899_695; - let pod = PodU64::from(n); - assert_eq!(u64::from(pod), n); - - // Test reference conversion - let pod_from_ref = PodU64::from(&n); - assert_eq!(u64::from(pod_from_ref), n); - - // Test max value - let max = PodU64::from(u64::MAX); - assert_eq!(u64::from(max), u64::MAX); - } - - #[test] - fn test_pod_u128() { - // Test zero - let zero = PodU128::default(); - assert_eq!(u128::from(zero), 0); - - // Test conversion from u128 - let n: u128 = 170_141_183_460_469_231_731_687_303_715_884_105_727; - let pod = PodU128::from(n); - assert_eq!(u128::from(pod), n); - - // Test reference conversion - let pod_from_ref = PodU128::from(&n); - assert_eq!(u128::from(pod_from_ref), n); - - // Test max value - let max = PodU128::from(u128::MAX); - assert_eq!(u128::from(max), u128::MAX); - } - - #[test] - fn test_pod_bool() { - // Test default is false - let default_bool = PodBool::default(); - assert_eq!(bool::from(default_bool), false); - - // Test true conversion - let true_bool = PodBool::from(true); - assert_eq!(bool::from(true_bool), true); - - // Test false conversion - let false_bool = PodBool::from(false); - assert_eq!(bool::from(false_bool), false); - - // Test reference conversion - let true_ref = true; - let pod_from_ref = PodBool::from(&true_ref); - assert_eq!(bool::from(pod_from_ref), true); - - // Test non-zero values are true - let non_zero = PodBool(2); - assert_eq!(bool::from(non_zero), true); - } - - #[test] - fn test_debug_formatting() { - // Test debug formatting for all types - assert_eq!(format!("{:?}", PodU16::from(12345)), "PodU16(12345)"); - assert_eq!( - format!("{:?}", PodU32::from(305419896)), - "PodU32(305419896)" - ); - assert_eq!( - format!("{:?}", PodU64::from(1311768467294899695)), - "PodU64(1311768467294899695)" - ); - assert_eq!( - format!( - "{:?}", - PodU128::from(170141183460469231731687303715884105727) - ), - "PodU128(170141183460469231731687303715884105727)" - ); - assert_eq!(format!("{:?}", PodBool::from(true)), "PodBool(true)"); - assert_eq!(format!("{:?}", PodBool::from(false)), "PodBool(false)"); - } - - #[test] - fn test_byte_representation() { - // Test that the byte representation is correct (little-endian) - let n: u16 = 0x1234; - let pod = PodU16::from(n); - assert_eq!(pod.0, [0x34, 0x12]); - - let n: u32 = 0x12345678; - let pod = PodU32::from(n); - assert_eq!(pod.0, [0x78, 0x56, 0x34, 0x12]); - - let n: u64 = 0x1234567890ABCDEF; - let pod = PodU64::from(n); - assert_eq!(pod.0, [0xEF, 0xCD, 0xAB, 0x90, 0x78, 0x56, 0x34, 0x12]); - } - - #[test] - fn test_pod_properties() { - // Test that Pod types implement expected traits - fn assert_pod() {} - - assert_pod::(); - assert_pod::(); - assert_pod::(); - assert_pod::(); - assert_pod::(); - } -} diff --git a/makefile b/makefile index ef26df1c..91296138 100644 --- a/makefile +++ b/makefile @@ -43,9 +43,8 @@ generate-idl: --module-paths "restaking_sdk" \ --module-paths "restaking_core" \ --module-paths "restaking_program" \ - --module-paths "bytemuck" \ --module-paths "core" - + $(SHANK_CLI) \ --program-env-path $(ENV_PATH) \ --output-idl-path $(IDL_OUTPUT_PATH) \ @@ -55,7 +54,6 @@ generate-idl: --module-paths "vault_sdk" \ --module-paths "vault_core" \ --module-paths "vault_program" \ - --module-paths "bytemuck" \ --module-paths "core" # Build debug