0

Creating a CPI call, since it returns a Result. If the internal call throws an error, err should have an err() field as per the definition. The whole transaction should not revert, but it is reverting. Is there another way to achieve the same? I tried with Solana's native invocation invoke_signed as well.

    let res: std::prelude::v1::Result<message_handler_interface::cpi::Return<Vec<u8>>, Error> =
        message_handler_interface::cpi::handle_message(
            handle_message_ctx,
            dst_token,
            relay_data.amount,
        );

1 Answer 1

1

Way back when, in 2020, it was possible to catch errors during CPI, which is why invoke_signed returns a Result type.

Due to the cost of handling reverting changes to accounts during CPI, though, that functionality was disabled, but the invoke_signed function signature wasn't updated to reflect that change.

All that to say, it is currently impossible for a program to recover from an inner error during CPI.

2
  • Thanks, since I wanted this for program, is it possible in some other way or not at all Commented May 15 at 17:44
  • 1
    It's currently impossible
    – Jon C
    Commented May 16 at 10:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.