wormhole-foundation / example-liquidity-layer

Apache License 2.0
11 stars 11 forks source link

solana: figure out why solana CLI >=1.17 doesn't work #71

Closed a5-pickle closed 4 months ago

a5-pickle commented 5 months ago

With 1.17, test validator dies with validator logs resembling:

note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
thread 'solRpcEl' panicked at runtime/src/bank.rs:4387:14:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0: rust_begin_unwind
             at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/panicking.rs:595:5
   1: core::panicking::panic_fmt
             at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/core/src/panicking.rs:67:14
   2: core::panicking::panic
             at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/core/src/panicking.rs:117:5
   3: solana_runtime::bank::Bank::simulate_transaction_unchecked
   4: solana_runtime::bank::Bank::simulate_transaction
   5: <solana_rpc::rpc::rpc_full::FullImpl as solana_rpc::rpc::rpc_full::rpc_impl_Full::gen_server::Full>::send_transaction
   6: <jsonrpc_core::delegates::DelegateMethodWithMeta<T,F> as jsonrpc_core::calls::RpcMethod<M>>::call
   7: jsonrpc_core::middleware::Middleware::on_call
   8: jsonrpc_core::io::MetaIoHandler<T,S>::handle_request
   9: jsonrpc_http_server::handler::RpcHandler<M,S>::process_body
  10: <jsonrpc_http_server::handler::RpcHandler<M,S> as core::future::future::Future>::poll
  11: <jsonrpc_http_server::handler::RpcHandler<M,S> as core::future::future::Future>::poll
  12: hyper::proto::h1::dispatch::Dispatcher<D,Bs,I,T>::poll_inner
  13: hyper::proto::h1::dispatch::Dispatcher<D,Bs,I,T>::poll_catch
  14: <hyper::server::conn::upgrades::UpgradeableConnection<I,S,E> as core::future::future::Future>::poll
  15: <hyper::server::server::new_svc::NewSvcTask<I,N,S,E,W> as core::future::future::Future>::poll
  16: tokio::loom::std::unsafe_cell::UnsafeCell<T>::with_mut
  17: tokio::runtime::task::core::Core<T,S>::poll
  18: tokio::runtime::task::harness::Harness<T,S>::poll
  19: tokio::runtime::scheduler::multi_thread::worker::Context::run_task
  20: tokio::runtime::scheduler::multi_thread::worker::Context::run
  21: tokio::runtime::context::scoped::Scoped<T>::set
  22: tokio::runtime::context::runtime::enter_runtime
  23: tokio::runtime::scheduler::multi_thread::worker::run
  24: tokio::loom::std::unsafe_cell::UnsafeCell<T>::with_mut
  25: tokio::runtime::task::core::Core<T,S>::poll
  26: tokio::runtime::task::harness::Harness<T,S>::poll
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

With >=1.18, <1.18.8, stack errors occur when invoking any instructions even with a refactor of account contexts.

And with >=1.18.8, stack errors can be resolved with a refactor of account contexts, but there is an issue with deserialization. One example is with the initialize instruction, where inputs resemble:

    const auctionParams: AuctionParameters = {
        userPenaltyRewardBps: 250_000, // 25%
        initialPenaltyBps: 250_000, // 25%
        duration: 2,
        gracePeriod: 5,
        penaltyPeriod: 10,
        minOfferDeltaBps: 20_000, // 2%
        securityDepositBase: uint64ToBN(4_200_000n),
        securityDepositBps: 5_000, // 0.5%
    };

But when debugging the Anchor instruction data, we get:

AuctionParameters { user_penalty_reward_bps: 1183200, initial_penalty_bps: 0, duration: 11768, grace_period: 0, penalty_period: 2, min_offer_delta_bps: 32720, security_deposit_base: 4200000, security_deposit_bps: 3 }

So right now, it is impossible to consider building without solana CLI 1.16.27.

a5-pickle commented 5 months ago

Consider using https://github.com/coral-xyz/anchor/pull/2766.

When using the anchor lang fork, be sure to use this:

[patch.crates-io]
anchor-lang = { git = ... }
anchor-spl = { git = ... }
a5-pickle commented 5 months ago

And may be related to https://github.com/coral-xyz/anchor/issues/2835.

a5-pickle commented 5 months ago

With 1.17, test validator dies with validator logs resembling:

Attaching an example log here. validator-1708006722959.log

a5-pickle commented 5 months ago

Be careful with CI like here: https://github.com/wormhole-foundation/example-native-token-transfers/pull/391.

a5-pickle commented 5 months ago

In playing around with upticking another repo to Anchor 0.30.0, there may be hope here.

Use Solana CLI >=1.18.10, solana_program >=1.18.10, update avm and anchor CLIs to 0.30.0.

Also be aware of this: https://github.com/anza-xyz/agave/issues/522, which will require us to write a custom script to load forked programs because any instruction that performs CPI to any of these loaded programs will cause the following error in our test validator:

SendTransactionError: failed to send transaction: Transaction simulation failed: This program may not be used for executing instructions