Nyzo techRelease notesNyzo 517: balance list performance

Nyzo 517: balance list performance

Nyzo version 517 (commit on GitHub) reduces the workload for servicing requests for balance lists. It also adds a new request and response for providing the balance list of the verifier's current frozen edge. This request and response will take the place of the initial balance list of block requests, and future versions of the verifier will no longer provide initial balance lists for such requests.

This version primarily affects the verifier. Some of the affected code paths are used by the sentinel, but the changes are insignificant to the operation of the sentinel.

To conserve memory, few balance lists are stored in BalanceListManager at any one time. While the BalanceListManager is able to calculate the balance list for any height between the retention edge and frozen edge on demand, such calculations can be computationally intensive. This version makes some small changes to provide immediate reductions in the computational load of verifiers. It also provides a new message that will be the basis of future, more substantial improvements in the handling of balance lists.

In BalanceListItem, an override of toString() was added. This was added while testing the new BalanceListResponse message.

RN_517 code 0

In BalanceListManager, the TODO for removing the fields for Genesis, retention-edge, and frozen-edge balance lists has been eliminated. While these fields were initially added for testing only, they are now planned to take the place of balanceListMap in this class.

RN_517 code 1

The frozenEdgeList field is now updated immediately when a new frozen-edge balance list is available, and an accessor for this field has been added.

RN_517 code 2

In MeshListener, block responses are now provided with the requester's IP address. This allows the responses to limit how frequently a balance list is provided for each requesting IP. Also, the frozen-edge balance list response has been added.

RN_517 code 3

In the Message class, processContent() has been changed from an if/else structure to a switch statement. Typically, the Nyzo codebase avoids any premature return statements in methods (uses of a return before the last line of the method), as they can cause readability issues. Also, switch statements are avoided, as the Nyzo code also avoids any uncommonly used language features, regardless of how old or well-understood such features may be. In general, the Nyzo code strives to use as few features as possible, as often as possible, in an attempt to produce a codebase that is as readable and as predictable as it can be. However, in this particular case, a switch statement and early return statements suit the job that needs to be done far better than the previous if/else structure.

RN_517 code 4
RN_517 code 5

In the MessageType enum, types for the frozen-edge balance list request and response have been added.

RN_517 code 6

In NicknameManager.get(), a check for a null identifier has been added. This is not directly related to the changes in this version, but it was an issue that arose during testing.

RN_517 code 7

The BalanceListResponse class wraps a BalanceList object and implements the MessageObject interface. Balance-list responses are provided to each IP no more than once every 10 minutes.

RN_517 code 8

The BlockRequest class now also limits balance lists to no more than once every 10 minutes per requesting IP. In a later version, the option to retrieve initial balance lists with block requests will be eliminated entirely, which will move the computational burden of deriving the balance list at a desired height from the responding node to the requesting node.

RN_517 code 9