-
Notifications
You must be signed in to change notification settings - Fork 973
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
In memory testing #4562
base: master
Are you sure you want to change the base?
In memory testing #4562
Conversation
I don't think that's the reason, the upgrade is there to make sure that ledgers with upgrades can be externalized out of order (that's important due to how config changes impact the internal core state). #4012 is the issue for which this has been introduced. So I don't think we should remove this.
Yeah, I think that's the right course of the action. |
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 agree with @dmkozh that the upgrade-specific logic seems important to test here.
Alternatively, we can maybe go through the full upgrade arming process with BucketListDB support instead of cutting corners with direct ltx commits.
I think this is a good idea even independent of the details of this specific test. When possible, avoiding the corner-cutting should lead to a more realistic and better overall test IMO.
src/ledger/InMemoryLedgerTxn.h
Outdated
// in-memory ltx. However, we still want to test SQL backed offers. The | ||
// "never" committing root sets this flag to true such that offer-related | ||
// calls get based to the real SQL backed root | ||
AbstractLedgerTxnParent* const mRealRootForOffers; |
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.
Storing raw pointers like this always makes me a little nervous about the potential for dangling pointers. From the comment it looks like this is only intended to be used for testing, so maybe it's OK. If that's the case then the constructor should document this and throw if realRoot != nullptr
when BUILD_TESTS
isn't set. Otherwise I think this should be a smart pointer or optional type.
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.
Going through the PR a bit further, it looks like this whole class is only used for testing? If that's the case, then maybe the entire class should be behind BUILD_TESTS
so no one tries to use it inappropriately.
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.
InMemoryLedgerTxn
classes now behind BUILD_TESTS
. I think the raw pointer was left over from the initial prod implementation, but has been refactored to a reference.
@@ -1221,25 +1168,19 @@ int | |||
runNewDB(CommandLineArgs const& args) | |||
{ | |||
CommandLine::ConfigOption configOption; | |||
bool minimalForInMemoryMode = false; | |||
[[maybe_unused]] bool minimalForInMemoryMode = false; |
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.
Is there a reason to keep this variable around instead of removing it?
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.
See below
[[maybe_unused]] bool inMemory = false; | ||
[[maybe_unused]] uint32_t startAtLedger = 0; | ||
[[maybe_unused]] std::string startAtHash; |
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.
Is there a reason to keep these variables around?
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.
Ya, I want clara to be able to parse the flags so we don't throw and crash, but I don't want to actually use the variables. It takes a reference and idk what clara is doing under the hood, so I used separate variables like the library intended to be on the safe side.
@@ -419,23 +371,21 @@ clara::Opt | |||
inMemoryParser(bool& inMemory) | |||
{ | |||
return clara::Opt{inMemory}["--in-memory"]( | |||
"(DEPRECATED) store working ledger in memory rather than database"); | |||
"(DEPRECATED) flag is ignored and will be removed soon."); |
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.
Why not remove the argument altogether and let core fail to start? Same question goes for --start-at-ledger
and --start-at-hash
. I think that provides a better user experience than ignoring flags.
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.
This was specifically a request from platform. there are some Horizon configs that use this flag that are niche and no longer supported, but still exist in the codebase. They wanted us to just ignore the flags for now and not crash so that we don't have a breaking point release.
Got the test to work with BucketList friendly upgrades and pushed some cleanups around |
Description
Resolves #4501 and partially resolves 4502
This PR removes
--in-memory
. Specifically, core will not crash if this flag is passed in for Horizon compatibility reasons, but will ignore it and related flags.Additionally,
--in-memory
has been cannibalized to use in testing. Previously, any test that committed changes directly to the root ltx was incompatible with BucketListDB and required SQL. This is an issue, as we are deprecating SQL for ledger state, and it would not make sense to maintain this SQL overhead for testing only. While I've removed most of thein-memory
code, I've saved the bits regarding the never committing ledger root to use for the direct ltx commit test cases. Thus we remove the test dependency for SQL.In order to properly test the orderbook, the
in-memory
testing mode still maintains and queries a SQL database just for offers (similar to what BucketListDB does).Originally I did one PR for removing SQL,
--in-memory
and mandating background eviction. This was way to big to merge but may be helpful in providing context on what changes are in flight after this PR: #4504.Currently everything works except for the "herder externalizes values" test. With BucketListDB testing mode, nodes can be restarted, but direct ltx commits are not supported. With the in-memory mode testing, ltx can be committed to directly, but nodes can not be restarted.
For all tests except for "herder externalizes values", this if fine. However, "herder externalizes values" is the only test that both directly commits to the ltx and restarts nodes. In particular, thesetupUpgradeAtNextLedger
function directly commits to the ltx. I've seperated the test into two helper functions, one that doesn't require restart and one that does. I think that the restart test doesn't actually require an upgrade to occur. I think the test just used upgrades in order to populate ledgers with some meaningful, detectable work to make sure externalized ledgers aren't applied several times. If the upgrade operation is not integral to this test, we can probably find a workaround. Alternatively, we can maybe go through the full upgrade arming process with BucketListDB support instead of cutting corners with direct ltx commits. I'm not well versed in herder tests though, so I've left the failing test as is. If we can remove the upgrade and check the condition some other way, this is the path of least resistance.Test has been fixed to use upgrades compatible with BucketListDB.
Checklist
clang-format
v8.0.0 (viamake format
or the Visual Studio extension)