-
Notifications
You must be signed in to change notification settings - Fork 985
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
Include ledger sequence in preflight response #3560
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, but idk
@@ -220,9 +220,11 @@ InvokeHostFunctionOpFrame::preflight(Application& app, | |||
{ | |||
auto cb = std::make_unique<PreflightCallbacks>(app); | |||
Json::Value root; | |||
LedgerTxn ltx(app.getLedgerTxnRoot()); | |||
root["ledger"] = ltx.loadHeader().current().ledgerSeq; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason for moving ltx
out of the try/catch block? The constructor call throw and this would crash the node instead of returning an error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assumed that if the invoke function operation failed (e.g. the smart contract reverted) then that would throw an exception and we would enter the catch clause. In that casem it would still be nice to know the ledger sequence of the invoke function attempt.
I assumed that moving ltx
out of the try/catch block should be safe because we already do that in the get ledger entry endpoint:
stellar-core/src/main/CommandHandler.cpp
Lines 722 to 723 in e7f06ea
LedgerTxn ltx(mApp.getLedgerTxnRoot()); | |
root["ledger"] = ltx.loadHeader().current().ledgerSeq; |
Note how the same code is executed without any try / catch block in the handler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually commandhandler has a try/catch anyways at the top level (just returns a 500) so we're good
r+ e7f06ea |
Description
This commit adds a ledger sequence to the preflight response which is useful because execution of a smart contract will depend on the state of the ledger when the operation is applied.
Checklist
clang-format
v8.0.0 (viamake format
or the Visual Studio extension)