servalproject / serval-dna

The Serval Project's core daemon that implements Distributed Numbering Architecture (DNA), MDP, VoMP, Rhizome, MeshMS, etc.
http://servalproject.org
Other
170 stars 80 forks source link

Rhizome file list is too slow #17

Closed lakeman closed 11 years ago

lakeman commented 11 years ago

Servald is currently doing too much processing to determine which files you have published while retrieving the list of all files. We need to remove this check from the file listing, and add a separate command to perform this test that can be called from the file details activity.

quixotique commented 11 years ago

The problem occurs every time the Rhizome List activity is opened (select "Share" on the main screen then the "Find" button). It takes a very long time to populate the list of files, because the CPU is running at 100% checking signatures for every Rhizome file.

The reason for the check is for usability: it allows two different file lists to be presented to the user: the "Sent" list of files the user (or any currently open identity on the same phone) has shared, and the "Find" list of all other files received. Very analogous to the well-known "sent" and "inbox" email folders. For reasons of deniability, the Rhizome database does not record the authentic sender of bundles, so the servald rhizome list command must check every bundle against every Rhizome secret in the keyring to see if the bundle was authored here, and set the _selfsigned column to 0 or 1 accordingly.

The CPU cost of the _selfsigned column could be drastically reduced by (a) caching the result of the signature check in memory, so it only has to be computed once per session, and/or (b) introducing the concept of a "non deniable" or "secret" identity, and caching the _selfsigned result in the Rhizome database only for "non deniable" identities. Solution (b) would have the consequence that files shared by a secret identity would never appear in the "Sent" list, only the "Find" list, which is consistent with the notion of secrecy, so should not be too hard to explain in documentation or a FAQ.

The code where the CPU cost is incurred is https://github.com/servalproject/serval-dna/blob/7452c215e2cc1ee397497f469a8bf3d4083d279f/rhizome_database.c#L821

gardners commented 11 years ago

We should be able to disable the test for the "Find" list, because we don't care about authorship there, or do we want "Sent" and "Find" to be distinct lists?

lakeman commented 11 years ago

rhizome_list_manifests doesn't currently filter based on the selfsigned result. The user impact of selfsigned in Serval Mesh is only visible after the details of a file are examined.

The alternative is to remove the selfsigned column from the rhizome list command, and add a new command line query to perform this check for only one manifest.

Then Serval Mesh can delay this check until the detail window is opened. There wouldn't be any user visible impact and we wouldn't compromise the ideal of deniable publishing.

gardners commented 11 years ago

Sounds like a plan. WIll need to be integrated with Andrew's work on the test framework to make sure that we check it when we need to.

quixotique commented 11 years ago

Following further chat discussion with @gardners today, the plan is:

quixotique commented 11 years ago

A slight modification of the design described above:

The MANIFESTS table author column records the cryptographically verified SID of the author that has write permission on the bundle, ie, possesses the Rhizome secret key that generated the BID, and hence can derive the Bundle Secret from the bundle's BK field:

The sender is not stored as a MANIFESTS table column for the time being, just extracted from the manifest blob when needed.

The rhizome list command already had a sender column, so two new columns were added to replace the .selfsigned column:

The rhizome extract manifest command has two new output fields:

quixotique commented 11 years ago

After merging 839de7557c119328c56f07b0cbfa852da9ed02bd the new NaCl implementation and the Rhizome stress test branches, all tests PASS on Linux i686.

On Solaris, all tests PASS except the routing tests all FAIL and one directory_service test fails, due to an unrelated SIGBUS bug recently introduced in the servald mdp ping command.

Closing this issue.