drift-labs / gateway

Self hosted API gateway to easily interact with Drift V2 Protocol
Apache License 2.0
22 stars 12 forks source link

Panic in running on devnet #63

Closed denisadapt closed 2 months ago

denisadapt commented 4 months ago

*What happens@ Gateway panics right after startup

RUST_BACKTRACE=full ./drift-gateway --dev https://api.devnet.solana.com
thread 'main' panicked at /Users/dk/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bytemuck-1.16.1/src/internal.rs:32:3:
from_bytes>SizeMismatch
stack backtrace:
   0:        0x104d0fab8 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h01b2beffade888b2
   1:        0x104d2e018 - core::fmt::write::hbadb443a71b75f23
   2:        0x104d0d1b0 - std::io::Write::write_fmt::hc09d7755e3ead5f0
   3:        0x104d0f910 - std::sys_common::backtrace::print::h28349e5c25acbac7
   4:        0x104d10e24 - std::panicking::default_hook::{{closure}}::hd24b6196784d991e
   5:        0x104d10b08 - std::panicking::default_hook::hfcec80a2720c8c73
   6:        0x104d11718 - std::panicking::rust_panic_with_hook::h84760468187ddc85
   7:        0x104d11104 - std::panicking::begin_panic_handler::{{closure}}::he666a5eb600a7203
   8:        0x104d0ff3c - std::sys_common::backtrace::__rust_end_short_backtrace::h592f44d2bf9f843f
   9:        0x104d10e7c - _rust_begin_unwind
  10:        0x104d590e4 - core::panicking::panic_fmt::h98bbf7bdf4994454
  11:        0x104d4af9c - bytemuck::internal::something_went_wrong::haff791b326d90c27
  12:        0x104abc440 - <drift::state::spot_market::SpotMarket as anchor_lang::AccountDeserialize>::try_deserialize::h475dc85a9cc44bd5
  13:        0x10466aa0c - drift_sdk::marketmap::MarketMap<T>::sync::{{closure}}::h7ec0054aea725837
  14:        0x104666620 - <tokio::future::maybe_done::MaybeDone<Fut> as core::future::future::Future>::poll::hb6358749a8a5a57e
  15:        0x104760720 - <tokio::future::poll_fn::PollFn<F> as core::future::future::Future>::poll::h271b9f71661076c1
  16:        0x10471c7bc - drift_gateway::main::{{closure}}::h49ecf878d3caa115
  17:        0x10471a000 - <tokio::task::local::RunUntil<T> as core::future::future::Future>::poll::h031f73515da4ecfe
  18:        0x104718464 - <core::pin::Pin<P> as core::future::future::Future>::poll::hc7f389e6bbffa3e0
  19:        0x10475ef34 - tokio::runtime::scheduler::current_thread::Context::enter::hc89a52c8f07e3d02
  20:        0x1046a27d8 - tokio::runtime::context::scoped::Scoped<T>::set::h9391474464aeb2ae
  21:        0x10475f108 - tokio::runtime::scheduler::current_thread::CoreGuard::block_on::hfa9354fbf932df09
  22:        0x10471745c - tokio::runtime::context::runtime::enter_runtime::he7be0e39a8d5d899
  23:        0x104717770 - tokio::runtime::runtime::Runtime::block_on::h28c644f11b172d45
  24:        0x10464db5c - drift_gateway::main::hc90cd26909a551ca
  25:        0x10470bf70 - std::sys_common::backtrace::__rust_begin_short_backtrace::h8d44552cb670c296
  26:        0x10470ca24 - std::rt::lang_start::{{closure}}::h525516b1038c0948
  27:        0x104d09268 - std::rt::lang_start_internal::h39923ab4c3913741
  28:        0x10464e4e0 - _main

Versions Gateway: master, f7375d7e54d508706e6c2b838034d796301b9114 Rust: 1.78.0 Runs on macos 14.5 m1 pro

denisadapt commented 4 months ago

The same problem with mainnet. I have also tried to build with rust 1.76.0 but nothing has changed:

RUST_BACKTRACE=full target/debug/drift-gateway https://...
thread 'main' panicked at /Users/dk/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bytemuck-1.16.1/src/internal.rs:32:3:
from_bytes>SizeMismatch
stack backtrace:
   0:        0x1056e35b0 - std::backtrace_rs::backtrace::libunwind::trace::hadefa2fe489b32be
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:        0x1056e35b0 - std::backtrace_rs::backtrace::trace_unsynchronized::h37e8bb3c3fd9c67c
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:        0x1056e35b0 - std::sys_common::backtrace::_print_fmt::h4994a90b70e9aaa7
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/sys_common/backtrace.rs:68:5
   3:        0x1056e35b0 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hb478ebbfb46e27ce
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/sys_common/backtrace.rs:44:22
   4:        0x105700a8c - core::fmt::rt::Argument::fmt::hfe2e626e52db21d5
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/fmt/rt.rs:142:9
   5:        0x105700a8c - core::fmt::write::he4d5fa2daff1f531
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/fmt/mod.rs:1120:17
   6:        0x1056e0f28 - std::io::Write::write_fmt::hc5a47a68eba63d9f
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/io/mod.rs:1810:15
   7:        0x1056e33e4 - std::sys_common::backtrace::_print::hd47355bf70e1c2da
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/sys_common/backtrace.rs:47:5
   8:        0x1056e33e4 - std::sys_common::backtrace::print::h79bd952cc5812e7a
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/sys_common/backtrace.rs:34:9
   9:        0x1056e4970 - std::panicking::default_hook::{{closure}}::h82301f6222887737
  10:        0x1056e46b8 - std::panicking::default_hook::h1e49abbb3f1d7dbf
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:292:9
  11:        0x1056e4db8 - std::panicking::rust_panic_with_hook::h1e70c5d905e30e9d
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:779:13
  12:        0x1056e4cac - std::panicking::begin_panic_handler::{{closure}}::h399e32952efd26a4
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:657:13
  13:        0x1056e3a34 - std::sys_common::backtrace::__rust_end_short_backtrace::h2ab87f841a2323e7
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/sys_common/backtrace.rs:171:18
  14:        0x1056e4a34 - rust_begin_unwind
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:645:5
  15:        0x10572bf54 - core::panicking::panic_fmt::h33e40d2a93cab78f
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/panicking.rs:72:14
  16:        0x10571d388 - bytemuck::internal::something_went_wrong::h2c76839df5deec53
                               at /Users/dk/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bytemuck-1.16.1/src/internal.rs:32:3
  17:        0x104f4f65c - bytemuck::internal::from_bytes::hba3939783a30faed
                               at /Users/dk/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bytemuck-1.16.1/src/internal.rs:89:15
  18:        0x104f4f4d4 - bytemuck::from_bytes::h56936ce30611634d
                               at /Users/dk/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bytemuck-1.16.1/src/lib.rs:255:12
  19:        0x104f5e1b8 - <drift::state::spot_market::SpotMarket as anchor_lang::AccountDeserialize>::try_deserialize_unchecked::ha143aedd616bde54
                               at /Users/dk/.cargo/git/checkouts/protocol-v2-b91d1e7a5821079c/ba4529a/programs/drift/src/state/spot_market.rs:28:1
  20:        0x104f5e00c - <drift::state::spot_market::SpotMarket as anchor_lang::AccountDeserialize>::try_deserialize::h8521f16c4abf652c
                               at /Users/dk/.cargo/git/checkouts/protocol-v2-b91d1e7a5821079c/ba4529a/programs/drift/src/state/spot_market.rs:28:1
  21:        0x104485e7c - drift_sdk::utils::decode::hc228b444c9ccb563
                               at /Users/dk/.cargo/git/checkouts/drift-rs-5caec46913ba7527/bfb0be3/src/utils.rs:130:5
  22:        0x104485e7c - drift_sdk::marketmap::MarketMap<T>::sync::{{closure}}::ha2ab2a0cb43ba6b4
                               at /Users/dk/.cargo/git/checkouts/drift-rs-5caec46913ba7527/bfb0be3/src/marketmap.rs:221:28
  23:        0x1042f79e0 - <tokio::future::maybe_done::MaybeDone<Fut> as core::future::future::Future>::poll::hd0dde51ec2df8210
                               at /Users/dk/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/future/maybe_done.rs:62:56
  24:        0x1044c8954 - drift_sdk::DriftClientBackend<T>::new::{{closure}}::{{closure}}::h996fa2b93e6c2b48
                               at /Users/dk/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/macros/try_join.rs:172:24
  25:        0x10431c654 - <tokio::future::poll_fn::PollFn<F> as core::future::future::Future>::poll::hbc41e1956f2c734f
                               at /Users/dk/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/future/poll_fn.rs:58:9
  26:        0x1044c79bc - drift_sdk::DriftClientBackend<T>::new::{{closure}}::hc6a6617410d0d9b3
                               at /Users/dk/.cargo/git/checkouts/drift-rs-5caec46913ba7527/bfb0be3/src/lib.rs:724:34
  27:        0x1044c31e4 - drift_sdk::DriftClient<T>::new_with_opts::{{closure}}::hbcd879f638694f61
                               at /Users/dk/.cargo/git/checkouts/drift-rs-5caec46913ba7527/bfb0be3/src/lib.rs:345:68
  28:        0x1044c4818 - drift_sdk::DriftClient<T>::new::{{closure}}::hc50a686e72f1bb08
                               at /Users/dk/.cargo/git/checkouts/drift-rs-5caec46913ba7527/bfb0be3/src/lib.rs:334:87
  29:        0x1044fa2ac - drift_gateway::controller::AppState::new::{{closure}}::hc76c7143e174d9a7
                               at /Users/dk/develop/gateway/src/controller.rs:102:14
  30:        0x1044beb58 - drift_gateway::main::{{closure}}::hdaeddd9b9f1ed051
                               at /Users/dk/develop/gateway/src/main.rs:240:6
  31:        0x104404318 - <tokio::task::local::RunUntil<T> as core::future::future::Future>::poll::{{closure}}::hf4d796885b076b94
                               at /Users/dk/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/task/local.rs:978:42
  32:        0x104403eb0 - tokio::task::local::LocalSet::with::{{closure}}::h3826021aeda2ff70
                               at /Users/dk/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/task/local.rs:730:13
  33:        0x1043023d4 - std::thread::local::LocalKey<T>::try_with::h40ac234e39c56154
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/thread/local.rs:270:16
  34:        0x104301578 - std::thread::local::LocalKey<T>::with::hfdca3a7afd930952
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/thread/local.rs:246:9
  35:        0x104403e20 - tokio::task::local::LocalSet::with::h55026de33c1442d3
                               at /Users/dk/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/task/local.rs:728:9
  36:        0x104404290 - <tokio::task::local::RunUntil<T> as core::future::future::Future>::poll::ha84e00ef4cfef265
                               at /Users/dk/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/task/local.rs:968:9
  37:        0x104404160 - tokio::task::local::LocalSet::run_until::{{closure}}::hf49e7576b06ea2ea
                               at /Users/dk/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/task/local.rs:635:19
  38:        0x1044aeccc - <core::pin::Pin<P> as core::future::future::Future>::poll::h958102a584cf43d3
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/future/future.rs:124:9
  39:        0x1043106fc - tokio::runtime::scheduler::current_thread::CoreGuard::block_on::{{closure}}::{{closure}}::{{closure}}::h3b466fb2f883e3e5
                               at /Users/dk/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/runtime/scheduler/current_thread/mod.rs:659:57
  40:        0x104310658 - tokio::runtime::coop::with_budget::h6e5739d39357df6c
                               at /Users/dk/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/runtime/coop.rs:107:5
  41:        0x104310658 - tokio::runtime::coop::budget::h416b649398c28d58
                               at /Users/dk/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/runtime/coop.rs:73:5
  42:        0x104310658 - tokio::runtime::scheduler::current_thread::CoreGuard::block_on::{{closure}}::{{closure}}::hefb6e68300d74953
                               at /Users/dk/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/runtime/scheduler/current_thread/mod.rs:659:25
  43:        0x10430f76c - tokio::runtime::scheduler::current_thread::Context::enter::h5f09db04bf194869
                               at /Users/dk/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/runtime/scheduler/current_thread/mod.rs:404:19
  44:        0x104310044 - tokio::runtime::scheduler::current_thread::CoreGuard::block_on::{{closure}}::h3a6bfc0f43f8f03c
                               at /Users/dk/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/runtime/scheduler/current_thread/mod.rs:658:36
  45:        0x10430fe40 - tokio::runtime::scheduler::current_thread::CoreGuard::enter::{{closure}}::h9de4675a9a6a81d6
                               at /Users/dk/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/runtime/scheduler/current_thread/mod.rs:737:68
  46:        0x1043a3f20 - tokio::runtime::context::scoped::Scoped<T>::set::hc66126954721ab7f
                               at /Users/dk/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/runtime/context/scoped.rs:40:9
  47:        0x104496b70 - tokio::runtime::context::set_scheduler::{{closure}}::h42f5a1c50f1d9284
                               at /Users/dk/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/runtime/context.rs:180:26
  48:        0x104303d94 - std::thread::local::LocalKey<T>::try_with::haf25d41759506d0c
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/thread/local.rs:270:16
  49:        0x104301530 - std::thread::local::LocalKey<T>::with::hed48017da4edbec5
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/thread/local.rs:246:9
  50:        0x104496b30 - tokio::runtime::context::set_scheduler::h8bff7315c6825773
                               at /Users/dk/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/runtime/context.rs:180:9
  51:        0x10430fc68 - tokio::runtime::scheduler::current_thread::CoreGuard::enter::h76d7c88584a2b758
                               at /Users/dk/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/runtime/scheduler/current_thread/mod.rs:737:27
  52:        0x10430fe70 - tokio::runtime::scheduler::current_thread::CoreGuard::block_on::h4b66793f7929fd03
                               at /Users/dk/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/runtime/scheduler/current_thread/mod.rs:646:19
  53:        0x10430c220 - tokio::runtime::scheduler::current_thread::CurrentThread::block_on::{{closure}}::h40169e3f09b698e9
                               at /Users/dk/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/runtime/scheduler/current_thread/mod.rs:175:28
  54:        0x10444f06c - tokio::runtime::context::runtime::enter_runtime::hbf40ae114ce1140b
                               at /Users/dk/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/runtime/context/runtime.rs:65:16
  55:        0x10430c13c - tokio::runtime::scheduler::current_thread::CurrentThread::block_on::h2ba018e8d984f165
                               at /Users/dk/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/runtime/scheduler/current_thread/mod.rs:167:9
  56:        0x1043a6428 - tokio::runtime::runtime::Runtime::block_on::hecbf95a563f2fd9b
                               at /Users/dk/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/runtime/runtime.rs:347:47
  57:        0x104403f54 - tokio::task::local::LocalSet::block_on::h39b2ae1a7d8fc240
                               at /Users/dk/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.0/src/task/local.rs:592:9
  58:        0x104305638 - actix_rt::runtime::Runtime::block_on::hea768deb661b9d77
                               at /Users/dk/.cargo/registry/src/index.crates.io-6f17d22bba15001f/actix-rt-2.10.0/src/runtime.rs:138:9
  59:        0x1044029b0 - actix_rt::system::SystemRunner::block_on::hd92bc1fd9d96fc56
                               at /Users/dk/.cargo/registry/src/index.crates.io-6f17d22bba15001f/actix-rt-2.10.0/src/system.rs:244:9
  60:        0x104374ddc - drift_gateway::main::h55c7bc76e5c588bf
                               at /Users/dk/develop/gateway/src/main.rs:208:1
  61:        0x104342920 - core::ops::function::FnOnce::call_once::habcb71af2b5ad5c6
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/ops/function.rs:250:5
  62:        0x1044efe98 - std::sys_common::backtrace::__rust_begin_short_backtrace::h29b03f2496e631c8
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/sys_common/backtrace.rs:155:18
  63:        0x104397338 - std::rt::lang_start::{{closure}}::hd534ba1db2fef1b4
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/rt.rs:166:18
  64:        0x1056dcb14 - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::hde2a2ae1d756c37f
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/ops/function.rs:284:13
  65:        0x1056dcb14 - std::panicking::try::do_call::h96b73f4da16ee7c5
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:552:40
  66:        0x1056dcb14 - std::panicking::try::h2cb0c14c1266f147
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:516:19
  67:        0x1056dcb14 - std::panic::catch_unwind::hb8cd2580f659030d
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panic.rs:142:14
  68:        0x1056dcb14 - std::rt::lang_start_internal::{{closure}}::h00f9c2d0117ea0ef
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/rt.rs:148:48
  69:        0x1056dcb14 - std::panicking::try::do_call::h134dfd8876bcc105
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:552:40
  70:        0x1056dcb14 - std::panicking::try::h6595e056250d6043
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:516:19
  71:        0x1056dcb14 - std::panic::catch_unwind::haad85d5172c9b53a
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panic.rs:142:14
  72:        0x1056dcb14 - std::rt::lang_start_internal::hf4f3eb1e51305b96
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/rt.rs:148:20
  73:        0x104397304 - std::rt::lang_start::h7787c4fd6dca14d3
                               at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/rt.rs:165:17
  74:        0x104375974 - _main
jordy25519 commented 4 months ago

@denisadapt can you try compiling with x86 rust e.g.

softwareupdate --install-rosetta

rustup install 1.76.0-x86_64-apple-darwin
# from /gateway dir
rustup override set 1.76.0-x86_64-apple-darwin

solana programs do some memory transmutation stuff that relies on the x86_64 memory layout. thought this was in the README me already, will update it