Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Propagate cxx::Exception strings from preflight callbacks #3564

Merged

Conversation

graydon
Copy link
Contributor

@graydon graydon commented Oct 4, 2022

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-content HostError 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 the what() string from the cxx::Exception into the soroban host debug-event buffer, and then generate a HostError 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.

@MonsieurNicolas
Copy link
Contributor

r+ 33da135

@latobarita latobarita merged commit 5dccf37 into stellar:master Oct 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants