From b703a43fa13f8c6e7de17b3219739ce920f01e22 Mon Sep 17 00:00:00 2001 From: GroovieGermanikus Date: Mon, 16 Oct 2023 19:53:52 +0200 Subject: [PATCH 1/5] WIP - add some FAQ items --- README.md | 169 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 169 insertions(+) diff --git a/README.md b/README.md index a475ddce7..baa86dd10 100644 --- a/README.md +++ b/README.md @@ -46,3 +46,172 @@ note: the UI currently uses code directly from github, pointing to the ts-client - use `yarn publish` to release a new package, ensure compatibility with program release to mainnet-beta - fix the tag auto added by yarn to match our internal convention, see script `fix-npm-tag.sh`, tags should look like this e.g.`npm-v0.0.1`, note: the npm package version/tag should not necessarily match the latest program deployment + + +### FAQ (on-chain program) + +#### Not enough CU +*(CU: Compute Unit)* + +Although you want to keep an eye on the CU limit to make sure the program does not consume to many CUs, program integration test will fail unexpectedly if limit is too low when developing. + +Use this method to change the CU limit: +```rust +test.set_compute_max_units(500_000); +``` + + +#### Wrong Rust version + + +| Rust Version | Compatibility | Solana Version | +|-------------------------------------|---------------|---------------:| +| 1.69-x86_64-apple-darwin | works | 1.16.x | +| 1.66.1-x86_64-apple-darwin | works | 1.14.x | +| stable-x86_64-apple-darwin (1.69.0) | broken | 1.14.x | +| 1.68.2-x86_64-apple-darwin | broken | 1.14.x | +| 1.67.1-x86_64-apple-darwin | broken | 1.14.x | + +Check/set the version: +``` +rustup override list +# WRONG: +# /Users/username/code/mango-v4 1.69-aarch64-apple-darwin + +rustup override set 1.69-x86_64 +# CORRECT: +# /Users/username/code/mango-v4 1.69-x86_64 +``` + +The Rust version requirements for *Solana* and *Mango V4* can be found in the respective `rust-toolchain.toml` file. + +On *MacOS* its also required to use the x86 toolchain. + +#### Failed to create BPF VM: syscall #4389198304 was not registered before bind +This error results from wrong Rust version! + +*Solution*: see [Section about Rust version](#wrong-rust-version) + + +#### attempt to compute 0_usize - 1_usize, which would overflow +Multiple errors of this style are shown: +``` +666 | const_assert_eq!(size_of::(), size_of::()); +| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `0_usize - 1_usize`, which would overflow +``` + +Note: the assertion error text is misleading, the problem is not the overflow but the inequality of the two constants which cannot be optimized to zero by compiler. + +The problem appears on non-x86-targets (typically on MacOS). + +*Solution*: +Inspect your rust version and make sure you use the x86 toolchain - see [Section about Rust version](#wrong-rust-version) + + +#### Failed custom program error: 0x65 +(*anchor-related issue*) + +*Solution*: +Make sure that instruction layout (defined using Anchor) used by client/cpi matches the program version. + + +#### Program failed to complete: Access violation in stack frame 5 at address 0x200005ff8 of size 8 by instruction #6340 +No real solution yet! Please open an issue if you know how to fix this. + +*Workaround*: +Experiment with `#[inline(never)]` on methods. + + +#### instruction tries to borrow reference for an account which is already borrowed +(*anchor-related issue*) + +*Solution*: +Revisit the account references retrieved by explicit calls to `.load`/`.load_mut`. See doc on [`account_loader.rs`](https://github.com/coral-xyz/anchor/blob/fc9fd6d24b9be84abb2f40e47ed3faf7b11864ae/lang/src/accounts/account_loader.rs#L34). + + +#### Running on-chain program crash silently on VM when using rust logging + +*Solution*: +For Solana programs you must use `msg!` for logging and ***not*** `info!`/`debug!`/`error!`/`warn!`/`trace!` from the `log` crate. + + +#### Exceeded max BPF to BPF call depth of 64 at instruction #4605 (stack size exceeded) + +*Solution*: Fix the Rust version - see [Section about Rust version](#wrong-rust-version) + + +#### Program failed to complete: Invoked an instruction with data that is too large (12884928151 > 10240) + +*Solution*: +Fix the Solana version (1.15.2 worked). + + +#### Error: Function _ZN86_$LT$switchboard_v2..aggregator..AggregatorAccountData$u20$as$u20$core..fmt..Debug$GT$3fmt17h22734c1ad9ed3ea8E Stack offset of 4128 exceeded max offset of 4096 by 32 bytes, please minimize large stack variables +This error results from very large Rust structures passed as parameters. + +No solution yet! Please open an issue if you know how to fix this. + +As of now the problem can be ignored as long as the method is not called. + + +#### Syscall lib binding failes for invalid solana version combinations + +*Solution*: +Make sure the Solana version of the program is compatible with the validator version. + +Check the Solana Feature Gate status and the [Solana Feature Gate Activation Schedule](https://github.com/solana-labs/solana/wiki/Feature-Gate-Activation-Schedule): +``` +solana feature status + +# Output (truncated): +Feature | Status | Activation Slot | Description +7rcw5UtqgDTBBv2EcynNfYckgdAaH1MAsCjKgXMkN7Ri | active since epoch 516 | 217388260 | enable curve25519 syscalls +5x3825XS7M2A3Ekbn5VGGkvFoAg5qrRWkTrY4bARP1GL | inactive | NA | enable bpf upgradeable loader SetAuthorityChecked instruction #28424 + +Tool Feature Set: 4033350765 +Software Version Feature Set Stake RPC +1.17.1, 1.17.0 2241946265 2.20% 1.75% +1.16.17, 1.16.16, 1.16.15, 1.16.14 4033350765 9.12% 2.56% <-- me +1.16.13 3949673676 0.41% 0.27% +``` + + + + +#### Large Cpi Contexts (e.g. Serum) will eventually overflow the stack +No real solution yet! + +*Workaround*: Try to make method bodies smaller by extracting code into separate methods. + + +#### No log output or too noisy log output + +*Solution*: Configure the log filter: +``` +solana_rbpf=trace, solana_runtime::message_processor=debug, solana_runtime::system_instruction_processor=info, solana_program_test=debug, test_all=debug +``` + + +#### Error: toolchain 'bpf' is not installed +Solana programs require the special Rust toolchain to be installed. + + +*Solution*: +Use the proper toolchain when invoking `cargo` build or test: +``` +# 1.14.x +cargo +bpf build-bpf +# 1.15.x +cargo +sbf build-sbf +# 1.16.x +cargo +solana build-sbf +``` + +Make sure the toolcain is installed on your system: +``` +rustup toolchain list -v +``` + +If toolchain is missing use the *Solana Install Tool* [here](https://docs.solana.com/cli/install-solana-cli-tools) to install it. + + From 648711dc9214e7cb3aebf2256d5f1bfa689e2d0b Mon Sep 17 00:00:00 2001 From: GroovieGermanikus Date: Mon, 16 Oct 2023 21:48:10 +0200 Subject: [PATCH 2/5] typos --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index baa86dd10..67e4e672b 100644 --- a/README.md +++ b/README.md @@ -154,7 +154,7 @@ No solution yet! Please open an issue if you know how to fix this. As of now the problem can be ignored as long as the method is not called. -#### Syscall lib binding failes for invalid solana version combinations +#### Syscall lib binding fails for invalid solana version combinations *Solution*: Make sure the Solana version of the program is compatible with the validator version. @@ -207,7 +207,7 @@ cargo +sbf build-sbf cargo +solana build-sbf ``` -Make sure the toolcain is installed on your system: +Make sure the toolchain is installed on your system: ``` rustup toolchain list -v ``` From 3e5d829ede9f8b89c7a010158b3e1de7da343903 Mon Sep 17 00:00:00 2001 From: GroovieGermanikus Date: Wed, 18 Oct 2023 20:12:31 +0200 Subject: [PATCH 3/5] addressed review feedback: - typos - remove toolchain override - remove some old version references --- README.md | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 67e4e672b..fa2d66789 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ note: the UI currently uses code directly from github, pointing to the ts-client #### Not enough CU *(CU: Compute Unit)* -Although you want to keep an eye on the CU limit to make sure the program does not consume to many CUs, program integration test will fail unexpectedly if limit is too low when developing. +Although you want to keep an eye on the CU limit to make sure the program does not consume too many CUs, program integration test will fail unexpectedly if limit is too low when developing. Use this method to change the CU limit: ```rust @@ -63,29 +63,16 @@ test.set_compute_max_units(500_000); #### Wrong Rust version +The Rust version requirements for *Solana* and *Mango V4* can be found in the respective `rust-toolchain.toml` file. -| Rust Version | Compatibility | Solana Version | -|-------------------------------------|---------------|---------------:| -| 1.69-x86_64-apple-darwin | works | 1.16.x | -| 1.66.1-x86_64-apple-darwin | works | 1.14.x | -| stable-x86_64-apple-darwin (1.69.0) | broken | 1.14.x | -| 1.68.2-x86_64-apple-darwin | broken | 1.14.x | -| 1.67.1-x86_64-apple-darwin | broken | 1.14.x | +On *MacOS* its also required to use the x86 toolchain. -Check/set the version: ``` -rustup override list -# WRONG: -# /Users/username/code/mango-v4 1.69-aarch64-apple-darwin - rustup override set 1.69-x86_64 # CORRECT: # /Users/username/code/mango-v4 1.69-x86_64 ``` -The Rust version requirements for *Solana* and *Mango V4* can be found in the respective `rust-toolchain.toml` file. - -On *MacOS* its also required to use the x86 toolchain. #### Failed to create BPF VM: syscall #4389198304 was not registered before bind This error results from wrong Rust version! @@ -143,7 +130,7 @@ For Solana programs you must use `msg!` for logging and ***not*** `info!`/`debug #### Program failed to complete: Invoked an instruction with data that is too large (12884928151 > 10240) *Solution*: -Fix the Solana version (1.15.2 worked). +Use the Solana version 1.16.x or later. #### Error: Function _ZN86_$LT$switchboard_v2..aggregator..AggregatorAccountData$u20$as$u20$core..fmt..Debug$GT$3fmt17h22734c1ad9ed3ea8E Stack offset of 4128 exceeded max offset of 4096 by 32 bytes, please minimize large stack variables @@ -179,6 +166,8 @@ Software Version Feature Set Stake RPC #### Large Cpi Contexts (e.g. Serum) will eventually overflow the stack +Calls from one program to another program (i.e. CPI) requires a context data object to be prepared and passed as parameter. +This context object is very large for Serum and will eventually overflow the stack. No real solution yet! *Workaround*: Try to make method bodies smaller by extracting code into separate methods. @@ -186,7 +175,9 @@ No real solution yet! #### No log output or too noisy log output -*Solution*: Configure the log filter: +*Solution*: Configure the log filter. + +Start with this filter using the `RUST_LOG` environment variable: ``` solana_rbpf=trace, solana_runtime::message_processor=debug, solana_runtime::system_instruction_processor=info, solana_program_test=debug, test_all=debug ``` @@ -204,7 +195,7 @@ cargo +bpf build-bpf # 1.15.x cargo +sbf build-sbf # 1.16.x -cargo +solana build-sbf +cargo +solana build-sbf # or just `cargo build-sbf` ``` Make sure the toolchain is installed on your system: From 37f6d255b0683199c71e5a4b9ae4b0aba434868e Mon Sep 17 00:00:00 2001 From: GroovieGermanikus Date: Wed, 18 Oct 2023 20:12:31 +0200 Subject: [PATCH 4/5] addressed review feedback: - typos - remove toolchain override - remove some old version references --- README.md | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 67e4e672b..cc34aa3a1 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ note: the UI currently uses code directly from github, pointing to the ts-client #### Not enough CU *(CU: Compute Unit)* -Although you want to keep an eye on the CU limit to make sure the program does not consume to many CUs, program integration test will fail unexpectedly if limit is too low when developing. +Although you want to keep an eye on the CU limit to make sure the program does not consume too many CUs, program integration test will fail unexpectedly if limit is too low when developing. Use this method to change the CU limit: ```rust @@ -63,29 +63,21 @@ test.set_compute_max_units(500_000); #### Wrong Rust version +The Rust version requirements for *Solana* and *Mango V4* can be found in the respective `rust-toolchain.toml` file. -| Rust Version | Compatibility | Solana Version | -|-------------------------------------|---------------|---------------:| -| 1.69-x86_64-apple-darwin | works | 1.16.x | -| 1.66.1-x86_64-apple-darwin | works | 1.14.x | -| stable-x86_64-apple-darwin (1.69.0) | broken | 1.14.x | -| 1.68.2-x86_64-apple-darwin | broken | 1.14.x | -| 1.67.1-x86_64-apple-darwin | broken | 1.14.x | - -Check/set the version: +Check with this command: +``` +rustup show ``` -rustup override list -# WRONG: -# /Users/username/code/mango-v4 1.69-aarch64-apple-darwin +On *MacOS* its also required to use the x86 toolchain. + +``` rustup override set 1.69-x86_64 # CORRECT: # /Users/username/code/mango-v4 1.69-x86_64 ``` -The Rust version requirements for *Solana* and *Mango V4* can be found in the respective `rust-toolchain.toml` file. - -On *MacOS* its also required to use the x86 toolchain. #### Failed to create BPF VM: syscall #4389198304 was not registered before bind This error results from wrong Rust version! @@ -143,7 +135,7 @@ For Solana programs you must use `msg!` for logging and ***not*** `info!`/`debug #### Program failed to complete: Invoked an instruction with data that is too large (12884928151 > 10240) *Solution*: -Fix the Solana version (1.15.2 worked). +Use the Solana version 1.16.x or later. #### Error: Function _ZN86_$LT$switchboard_v2..aggregator..AggregatorAccountData$u20$as$u20$core..fmt..Debug$GT$3fmt17h22734c1ad9ed3ea8E Stack offset of 4128 exceeded max offset of 4096 by 32 bytes, please minimize large stack variables @@ -179,6 +171,8 @@ Software Version Feature Set Stake RPC #### Large Cpi Contexts (e.g. Serum) will eventually overflow the stack +Calls from one program to another program (i.e. CPI) requires a context data object to be prepared and passed as parameter. +This context object is very large for Serum and will eventually overflow the stack. No real solution yet! *Workaround*: Try to make method bodies smaller by extracting code into separate methods. @@ -186,7 +180,9 @@ No real solution yet! #### No log output or too noisy log output -*Solution*: Configure the log filter: +*Solution*: Configure the log filter. + +Start with this filter using the `RUST_LOG` environment variable: ``` solana_rbpf=trace, solana_runtime::message_processor=debug, solana_runtime::system_instruction_processor=info, solana_program_test=debug, test_all=debug ``` @@ -204,7 +200,7 @@ cargo +bpf build-bpf # 1.15.x cargo +sbf build-sbf # 1.16.x -cargo +solana build-sbf +cargo +solana build-sbf # or just `cargo build-sbf` ``` Make sure the toolchain is installed on your system: From 37195b5f835b1e681795469149010bced1876ac2 Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Tue, 7 Nov 2023 09:02:07 +0100 Subject: [PATCH 5/5] separate file, editing --- FAQ-DEV.md | 157 +++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 167 +---------------------------------------------------- 2 files changed, 158 insertions(+), 166 deletions(-) create mode 100644 FAQ-DEV.md diff --git a/FAQ-DEV.md b/FAQ-DEV.md new file mode 100644 index 000000000..a51c2cdb4 --- /dev/null +++ b/FAQ-DEV.md @@ -0,0 +1,157 @@ +# FAQ (on-chain program) + + +## Not enough CU in program tests + +Although you want to keep an eye on the CU (compute unit) limit to make sure the program does not consume too many CUs, program integration test will fail unexpectedly if limit is too low when developing. + +Use this method to change the CU limit: +```rust +test_builder.test().set_compute_max_units(500_000); +``` + + +## Wrong Rust version + +The Rust version requirements for *Solana* and *Mango V4* can be found in the respective `rust-toolchain.toml` file +and tools like *cargo* pick up on them automatically. + +Check with this command: +``` +rustup show +``` + +On *MacOS* its also required to use the x86 toolchain. + +``` +rustup override set 1.69-x86_64 +# CORRECT: +# /Users/username/code/mango-v4 1.69-x86_64 +``` + + +## Failed to create BPF VM: syscall #4389198304 was not registered before bind + +This error results from wrong Rust version! + +*Solution*: see [Section about Rust version](#wrong-rust-version) + + +## attempt to compute 0_usize - 1_usize, which would overflow + +Multiple errors of this style are shown: +``` +666 | const_assert_eq!(size_of::(), size_of::()); +| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `0_usize - 1_usize`, which would overflow +``` + +Note: the assertion error text is misleading, the problem is not the overflow but the static assert about struct sizes failing. + +The problem appears on non-x86-targets (typically on MacOS) that produce different struct layouts than are expected on-chain. For performance reasons the mango program wants to do zero-copy deserialization of account state and for that it's essential to be able to define structs that match the on-chain data layout. The assert failing means that that didn't work on this target. + +*Solution*: +For now, the only solution is to use an x86 toolchain - see [Section about Rust version](#wrong-rust-version) + + +## Failed custom program error: 0x65 + +(*anchor-related issue*) + +*Solution*: +Make sure that instruction layout (defined using Anchor) used by client/cpi matches the program version. + + +## Program failed to complete: Access violation in stack frame 5 at address 0x200005ff8 of size 8 by instruction #6340 + +The solana runtime provides limited stack space to each callframe and likely you are exceeding it. + +*Workaround*: +Avoid putting large data on the stack. Experiment with `#[inline(never)]` on methods. + + +## instruction tries to borrow reference for an account which is already borrowed + +(*anchor-related issue*) + +*Solution*: +Revisit the account references retrieved by explicit calls to `.load`/`.load_mut`. See doc on [`account_loader.rs`](https://github.com/coral-xyz/anchor/blob/fc9fd6d24b9be84abb2f40e47ed3faf7b11864ae/lang/src/accounts/account_loader.rs#L34). + + +## Running on-chain program crashes silently on VM when using rust logging + +*Solution*: +For Solana programs you must use `msg!` for logging and ***not*** `info!`/`debug!`/`error!`/`warn!`/`trace!` from the `log` crate. + + +## Exceeded max BPF to BPF call depth of 64 at instruction #4605 (stack size exceeded) + +*Solution*: Fix the Rust version - see [Section about Rust version](#wrong-rust-version) + + +## Program failed to complete: Invoked an instruction with data that is too large (12884928151 > 10240) + +*Solution*: +Use the Solana version 1.16.x or later. + + +## Error: Function _ZN86_$LT$switchboard_v2..aggregator..AggregatorAccountData$u20$as$u20$core..fmt..Debug$GT$3fmt17h22734c1ad9ed3ea8E Stack offset of 4128 exceeded max offset of 4096 by 32 bytes, please minimize large stack variables + +This error results from very large Rust structures passed as parameters. + +No solution yet! Please open an issue if you know how to fix this. + +As of now the problem can be ignored as long as the method is not called. + + +## Syscall lib binding fails for invalid solana version combinations + +*Solution*: +Make sure the Solana version of the program is compatible with the validator version. + +Check the Solana Feature Gate status and the [Solana Feature Gate Activation Schedule](https://github.com/solana-labs/solana/wiki/Feature-Gate-Activation-Schedule): +``` +solana feature status + +# Output (truncated): +Feature | Status | Activation Slot | Description +7rcw5UtqgDTBBv2EcynNfYckgdAaH1MAsCjKgXMkN7Ri | active since epoch 516 | 217388260 | enable curve25519 syscalls +5x3825XS7M2A3Ekbn5VGGkvFoAg5qrRWkTrY4bARP1GL | inactive | NA | enable bpf upgradeable loader SetAuthorityChecked instruction #28424 + +Tool Feature Set: 4033350765 +Software Version Feature Set Stake RPC +1.17.1, 1.17.0 2241946265 2.20% 1.75% +1.16.17, 1.16.16, 1.16.15, 1.16.14 4033350765 9.12% 2.56% <-- me +1.16.13 3949673676 0.41% 0.27% +``` + + +## No log output or too noisy log output + +*Solution*: Configure the log filter. + +Start with this filter using the `RUST_LOG` environment variable: +``` +solana_rbpf=trace, solana_runtime::message_processor=debug, solana_runtime::system_instruction_processor=info, solana_program_test=debug, test_all=debug +``` + + +## Error: toolchain 'bpf' is not installed + +Solana programs require the special Rust toolchain to be installed. +Normally the solana tooling installs it automatically on first use and `cargo build-sbf` will just work. + +*Workaround*: +Explicitly mention the toolchain when invoking `cargo` build or test: +``` +# 1.16.x +cargo +solana build-sbf +``` + +Make sure the toolchain is installed on your system: +``` +rustup toolchain list -v +``` + +If toolchain is missing use the *Solana Install Tool* [here](https://docs.solana.com/cli/install-solana-cli-tools) to install it. + + diff --git a/README.md b/README.md index cc34aa3a1..d3bccefe8 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ available under GPL. ## Development -See DEVELOPING.md +See DEVELOPING.md and FAQ-DEV.md ### Dependencies @@ -46,168 +46,3 @@ note: the UI currently uses code directly from github, pointing to the ts-client - use `yarn publish` to release a new package, ensure compatibility with program release to mainnet-beta - fix the tag auto added by yarn to match our internal convention, see script `fix-npm-tag.sh`, tags should look like this e.g.`npm-v0.0.1`, note: the npm package version/tag should not necessarily match the latest program deployment - - -### FAQ (on-chain program) - -#### Not enough CU -*(CU: Compute Unit)* - -Although you want to keep an eye on the CU limit to make sure the program does not consume too many CUs, program integration test will fail unexpectedly if limit is too low when developing. - -Use this method to change the CU limit: -```rust -test.set_compute_max_units(500_000); -``` - - -#### Wrong Rust version - -The Rust version requirements for *Solana* and *Mango V4* can be found in the respective `rust-toolchain.toml` file. - -Check with this command: -``` -rustup show -``` - -On *MacOS* its also required to use the x86 toolchain. - -``` -rustup override set 1.69-x86_64 -# CORRECT: -# /Users/username/code/mango-v4 1.69-x86_64 -``` - - -#### Failed to create BPF VM: syscall #4389198304 was not registered before bind -This error results from wrong Rust version! - -*Solution*: see [Section about Rust version](#wrong-rust-version) - - -#### attempt to compute 0_usize - 1_usize, which would overflow -Multiple errors of this style are shown: -``` -666 | const_assert_eq!(size_of::(), size_of::()); -| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `0_usize - 1_usize`, which would overflow -``` - -Note: the assertion error text is misleading, the problem is not the overflow but the inequality of the two constants which cannot be optimized to zero by compiler. - -The problem appears on non-x86-targets (typically on MacOS). - -*Solution*: -Inspect your rust version and make sure you use the x86 toolchain - see [Section about Rust version](#wrong-rust-version) - - -#### Failed custom program error: 0x65 -(*anchor-related issue*) - -*Solution*: -Make sure that instruction layout (defined using Anchor) used by client/cpi matches the program version. - - -#### Program failed to complete: Access violation in stack frame 5 at address 0x200005ff8 of size 8 by instruction #6340 -No real solution yet! Please open an issue if you know how to fix this. - -*Workaround*: -Experiment with `#[inline(never)]` on methods. - - -#### instruction tries to borrow reference for an account which is already borrowed -(*anchor-related issue*) - -*Solution*: -Revisit the account references retrieved by explicit calls to `.load`/`.load_mut`. See doc on [`account_loader.rs`](https://github.com/coral-xyz/anchor/blob/fc9fd6d24b9be84abb2f40e47ed3faf7b11864ae/lang/src/accounts/account_loader.rs#L34). - - -#### Running on-chain program crash silently on VM when using rust logging - -*Solution*: -For Solana programs you must use `msg!` for logging and ***not*** `info!`/`debug!`/`error!`/`warn!`/`trace!` from the `log` crate. - - -#### Exceeded max BPF to BPF call depth of 64 at instruction #4605 (stack size exceeded) - -*Solution*: Fix the Rust version - see [Section about Rust version](#wrong-rust-version) - - -#### Program failed to complete: Invoked an instruction with data that is too large (12884928151 > 10240) - -*Solution*: -Use the Solana version 1.16.x or later. - - -#### Error: Function _ZN86_$LT$switchboard_v2..aggregator..AggregatorAccountData$u20$as$u20$core..fmt..Debug$GT$3fmt17h22734c1ad9ed3ea8E Stack offset of 4128 exceeded max offset of 4096 by 32 bytes, please minimize large stack variables -This error results from very large Rust structures passed as parameters. - -No solution yet! Please open an issue if you know how to fix this. - -As of now the problem can be ignored as long as the method is not called. - - -#### Syscall lib binding fails for invalid solana version combinations - -*Solution*: -Make sure the Solana version of the program is compatible with the validator version. - -Check the Solana Feature Gate status and the [Solana Feature Gate Activation Schedule](https://github.com/solana-labs/solana/wiki/Feature-Gate-Activation-Schedule): -``` -solana feature status - -# Output (truncated): -Feature | Status | Activation Slot | Description -7rcw5UtqgDTBBv2EcynNfYckgdAaH1MAsCjKgXMkN7Ri | active since epoch 516 | 217388260 | enable curve25519 syscalls -5x3825XS7M2A3Ekbn5VGGkvFoAg5qrRWkTrY4bARP1GL | inactive | NA | enable bpf upgradeable loader SetAuthorityChecked instruction #28424 - -Tool Feature Set: 4033350765 -Software Version Feature Set Stake RPC -1.17.1, 1.17.0 2241946265 2.20% 1.75% -1.16.17, 1.16.16, 1.16.15, 1.16.14 4033350765 9.12% 2.56% <-- me -1.16.13 3949673676 0.41% 0.27% -``` - - - - -#### Large Cpi Contexts (e.g. Serum) will eventually overflow the stack -Calls from one program to another program (i.e. CPI) requires a context data object to be prepared and passed as parameter. -This context object is very large for Serum and will eventually overflow the stack. -No real solution yet! - -*Workaround*: Try to make method bodies smaller by extracting code into separate methods. - - -#### No log output or too noisy log output - -*Solution*: Configure the log filter. - -Start with this filter using the `RUST_LOG` environment variable: -``` -solana_rbpf=trace, solana_runtime::message_processor=debug, solana_runtime::system_instruction_processor=info, solana_program_test=debug, test_all=debug -``` - - -#### Error: toolchain 'bpf' is not installed -Solana programs require the special Rust toolchain to be installed. - - -*Solution*: -Use the proper toolchain when invoking `cargo` build or test: -``` -# 1.14.x -cargo +bpf build-bpf -# 1.15.x -cargo +sbf build-sbf -# 1.16.x -cargo +solana build-sbf # or just `cargo build-sbf` -``` - -Make sure the toolchain is installed on your system: -``` -rustup toolchain list -v -``` - -If toolchain is missing use the *Solana Install Tool* [here](https://docs.solana.com/cli/install-solana-cli-tools) to install it. - -