Propagate cxx::Exception strings from preflight callbacks #3564
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR does exception-explanation string propagation in an awkward context: when core's preflight endpoint calls the soroban host, and the soroban host calls core back to synchronously serve preflight ledger accesses, and then one of those ledger accesses fails and generates a C++ exception, which we receive back in Rust as a
cxx::Exception
(i.e. a bridge value carrying a string converted from the C++ exception).Before this PR, we just converted that
cxx::Exception
to a low-contentHostError
generated from a fairly uninformative status code. With this PR, we plumb a reference to the soroban host into the callbacks, so that we can record thewhat()
string from thecxx::Exception
into the soroban host debug-event buffer, and then generate aHostError
that captures that buffer, ultimately giving the user (and ultimately the core dev diagnosting the problem) a bit more context about the error.Doing this introduces an awkward temporary cyclical-ownership situation as well as an awkward potential borrow failure, but the former can be handled by explicitly breaking the edge after the call (as is done in the code here) and the latter can only fail with behavior no worse than the existing behavior.
All of this may be temporary, depending on the fate of (synchronous, dangerous) preflight-in-core. We might keep it around forever, hard to tell. But this change improves things for the time being.