MeteoraAg / dlmm-sdk

An SDK for building applications on top of Dynamic CLMM
56 stars 45 forks source link

TargetAlignmentGreaterAndInputNotAligned on LBPair #2

Open lagzda opened 8 months ago

lagzda commented 8 months ago

Hi there, I am getting the error - TargetAlignmentGreaterAndInputNotAligned whenever I try to load LbPair from program.account call on mainnet.

Any pointers?

codewithgun commented 8 months ago

Can you try use nightly-x86_64-apple-darwin toolchain?

0xc926ddba commented 5 months ago

Hi, @codewithgun I have the same issue on darwin though on aarch64 (apple m1 chip). All I'm trying to do is run the market_making example program. Using currently nightly causes ahash to fail to compile and I have also tried nightly-2024-01-15-aarch64-apple-darwin based on the date of your comment but still same error TargetAlignmentGreaterAndInputNotAligned. I've tried multiple pools with different tick spacing and fees as well and same issue.

Here's the trace:

from_bytes>TargetAlignmentGreaterAndInputNotAligned
stack backtrace:
   0: rust_begin_unwind
             at /rustc/30dfb9e046aeb878db04332c74de76e52fb7db10/library/std/src/panicking.rs:647:5
   1: core::panicking::panic_fmt
             at /rustc/30dfb9e046aeb878db04332c74de76e52fb7db10/library/core/src/panicking.rs:72:14
   2: bytemuck::internal::something_went_wrong
             at ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bytemuck-1.13.1/src/internal.rs:32:3
   3: bytemuck::internal::from_bytes
             at ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bytemuck-1.13.1/src/internal.rs:89:15
   4: bytemuck::from_bytes
             at ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bytemuck-1.13.1/src/lib.rs:190:12
   5: <lb_clmm::state::lb_pair::LbPair as anchor_lang::AccountDeserialize>::try_deserialize_unchecked
             at ~/code/meteora-dlamm/programs/lb_clmm/src/state/lb_pair.rs:79:1
   6: <lb_clmm::state::lb_pair::LbPair as anchor_lang::AccountDeserialize>::try_deserialize
             at ~/code/meteora-dlamm/programs/lb_clmm/src/state/lb_pair.rs:79:1
   7: anchor_client::Program<C>::account_internal::{{closure}}
             at ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/anchor-client-0.28.0/src/lib.rs:185:9
   8: anchor_client::nonblocking::<impl anchor_client::Program<C>>::account::{{closure}}
             at ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/anchor-client-0.28.0/src/nonblocking.rs:32:40
   9: market_making::core::Core::refresh_state::{{closure}}
             at ./src/core.rs:64:71
  10: market_making::main::{{closure}}
             at ./src/main.rs:134:26
  11: tokio::park::thread::CachedParkThread::block_on::{{closure}}
             at ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.14.1/src/park/thread.rs:263:54
  12: tokio::coop::with_budget::{{closure}}
             at ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.14.1/src/coop.rs:106:9
  13: std::thread::local::LocalKey<T>::try_with
             at /rustc/30dfb9e046aeb878db04332c74de76e52fb7db10/library/std/src/thread/local.rs:286:16
  14: std::thread::local::LocalKey<T>::with
             at /rustc/30dfb9e046aeb878db04332c74de76e52fb7db10/library/std/src/thread/local.rs:262:9
  15: tokio::coop::with_budget
             at ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.14.1/src/coop.rs:99:5
  16: tokio::coop::budget
             at ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.14.1/src/coop.rs:76:5
  17: tokio::park::thread::CachedParkThread::block_on
             at ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.14.1/src/park/thread.rs:263:31
  18: tokio::runtime::enter::Enter::block_on
             at ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.14.1/src/runtime/enter.rs:151:13
  19: tokio::runtime::thread_pool::ThreadPool::block_on
             at ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.14.1/src/runtime/thread_pool/mod.rs:77:9
  20: tokio::runtime::Runtime::block_on
             at ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.14.1/src/runtime/mod.rs:463:43
  21: market_making::main
             at ./src/main.rs:192:5
  22: core::ops::function::FnOnce::call_once
             at /rustc/30dfb9e046aeb878db04332c74de76e52fb7db10/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Process finished with exit code 101
miya9022 commented 4 months ago

I have a temp fix here. Add debug-assertions = false to Cargo.toml to solve this problem. But since this action undermine UB check on rust 1.70.0 though it should not be permanent solution.

jake-selini commented 4 days ago

hey folks any update on this? having the same issue attempting to parse LbPair accounts on mainnet, this is a major blocker. the proposed temp fix of adding debug-assertions = false to Cargo.toml doesn't seem to work for me either

jake-selini commented 4 days ago

update: did some digging and found out it's an issue with how newer versions of rust/llvm handle byte alignment - there's a number of open issues at Anchor reporting the same thing https://github.com/coral-xyz/anchor/issues/3114

downgrading rust to 1.76 fixed this issue for me