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

Shardstore Unittest Fix #3855

Closed
wants to merge 20 commits into from

Conversation

undertome
Copy link
Contributor

High Level Overview of Change

This fixes some recent failures in the shard database unit tests.

Context of Change

The unit test functions testDeterministicShard and testImportWithOnlineDelete were modified to fix test case failures. Please limit the review to 7778710 as this fix is stacked onto several unmerged PRs.

Type of Change

  • [x ] Bug fix (non-breaking change which fixes an issue)

mtrippled and others added 10 commits April 1, 2021 10:40
Typically, an RPC response contains a `result` field, which
contains details about the operation performed. For ease of
parsing, forwarded responses must look like a non-forwarded
response.

In some instances the response was incorrectly composed, so
that the actual `result` object would be encapsulated by an
outer `result` object, breaking existing code.

This commit, addresses this issue and correctly "folds" the
`result` field, ensuring a consistent schema for responses.
The `tx` command supports output in both "text" and "binary" modes,
controlled by the binary flag. For more details on the command and
the possible arguments, please see: https://xrpl.org/tx.html.

The existing handler would incorrectly deal with metadata when in
binary mode. This commit corrects this issue, ensuring that the
metadata is properly encoded, depending on the mode.
In order to effectively mitigate CVE-2021-3499 even when compiling
against versions of OpenSSL prior to 1.1.1k, this commit:

1) requires use of TLS 1.2 or later. Note that both TLS 1.0 and
   TLS 1.1 have been officially deprecated for over a year.
2) disables renegotiation support for TLS 1.2 connections.

Lastly, this commit also changes the default list of ciphers that
the server offers, limiting it only to ciphers that are part of
TLS 1.2.
* load_factor was missing from server_info when the server was running in
  reporting mode. Now, the reporting mode server calls server_info on the p2p
  node, and propagates the load_factor back to the client.
Substantial reductions in an offer's effective quality from its
initial quality may clog offer books.
* The std::less and std::equal_to comparators have [[nodiscard]], which
  conflicts with boost::bimap validations.
@scottschurr
Copy link
Collaborator

🎉

BEAST_EXPECT(
ripemd160File((path / "nudb.key").string()) == ripemd160Key);
BEAST_EXPECT(
ripemd160File((path / "nudb.dat").string()) == ripemd160Dat);
Copy link
Contributor

@miguelportilla miguelportilla May 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think these two checks are necessary here as we perform them at the end of the loop.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -1140,6 +1135,20 @@ class DatabaseShard_test : public TestBase
if (createShard(data, *db) < 0)
return;
}

Copy link
Contributor

@miguelportilla miguelportilla May 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The createShard call should be

if (!BEAST_EXPECT(createShard(data, *db) != std::nullopt))
    return;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't change anything, but this could also be written as

if (!BEAST_EXPECT(createShard(data, *db)))
    return;

or

if (!BEAST_EXPECT(createShard(data, *db).has_value()))
    return;

ripemd160File((path / "nudb.key").string()) == ripemd160Key);
BEAST_EXPECT(
ripemd160File((path / "nudb.dat").string()) == ripemd160Dat);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The waitShard call below should be

if (!BEAST_EXPECT(waitShard(*db, 1) != std::nullopt))
    return;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -1246,22 +1254,28 @@ class DatabaseShard_test : public TestBase
Database& ndb = env.app().getNodeStore();
BEAST_EXPECT(db);

auto const shardCount = 4;
// Create some ledgers for the shard store to
// import
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit. This comment can be a single line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

auto& store = env.app().getSHAMapStore();
auto lastRotated = store.getLastRotated();
// Enable online deletion now that the import has
// started
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit. This comment can be a single line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -1273,6 +1287,7 @@ class DatabaseShard_test : public TestBase
{
// A rotation occurred during shard import. Not
// necessarily an error

Copy link
Contributor

@miguelportilla miguelportilla May 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: sequence can be renamed to ledgerSeq and be const

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -1281,7 +1296,8 @@ class DatabaseShard_test : public TestBase
}
});

data = TestData(seedValue * 2, 4, shardCount);
// Create more ledgers to trigger online deletion
data = TestData(seedValue * 2, 4, 1);
Copy link
Contributor

@miguelportilla miguelportilla May 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to the defaults, can also be

TestData(seedValue * 2);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point - done

Copy link
Contributor

@miguelportilla miguelportilla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left some nit comments but otherwise looks good. 👍

undertome and others added 4 commits May 27, 2021 14:21
* Run the import process in a background thread
* Prevent online_delete from removing ledgers pending import
* Create SQLite database for mapping transaction IDs to shard indexes
* Create SQLite database for mapping ledger hashes to shard indexes
* Create additional test cases for the shard database
* resolves XRPLF#3782
* gcc 8 is required for the charconv include file
@undertome undertome force-pushed the shardstore-unittest-fix branch from a13cd9b to 0e7d5cc Compare June 1, 2021 19:40
This was referenced Jun 2, 2021
Copy link
Collaborator

@ximinez ximinez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is already merged, but I did look through it and everything looks good.

@@ -1140,6 +1135,20 @@ class DatabaseShard_test : public TestBase
if (createShard(data, *db) < 0)
return;
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't change anything, but this could also be written as

if (!BEAST_EXPECT(createShard(data, *db)))
    return;

or

if (!BEAST_EXPECT(createShard(data, *db).has_value()))
    return;

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.