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

perf(dapi)!: replace getMnListDiff with a streaming endpoint #1859

Merged
merged 68 commits into from
Jun 12, 2024

Conversation

shumkov
Copy link
Member

@shumkov shumkov commented May 26, 2024

Issue being fixed or feature implemented

Currently, the getMnListDiff endpoint allows to fetch masternode diff (dip-4) withing range of blocks. It uses the protx diff Core RPC which is very slow. DAPI client requests the initial list from genesis block to tip and then request the difference with new tip every several seconds.

To reduce load on the Core and network, we need to implement a streaming endpont that will keep masternode list and updates globaly for all client requests in DAPI. It will return full mn list from genesis to tip as a first message and update as sepatate messages every new block.

What was done?

  • Removed getMnListDiff from DAPI and DAPI Client
  • Introduced subscribeToMasternodeList endpoint to DAPI with global state to prevent extra calls to Core RPC
  • Fixed auto-reconnect to DAPI stream when the stream is stopped.

How Has This Been Tested?

During the testing, we noticed that on CI (probably the specific browser version for linux is affected) one of the streams stopped receiving messages. It's quite an old Brave browser from 2022. We weren't able to reproduce it locally or in other environments. A theory was that it was because of the number of open streams but it wasn't the case. At least not directly. To solve this problem I would recommend upgrading gRPC stack which is super outdated. gRPC Web library was updated in the 2021 year. The goal of this PR is not to fix the existing gRPC Web problem but to protect the DAPI endpoint. We skipped a couple of tests to be run in a browser and it helped for some reason.

Breaking Changes

getMnListDiff endoint is removed

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have added "!" to the title and described breaking changes in the corresponding section if my code contains any
  • I have made corresponding changes to the documentation if needed

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

@shumkov shumkov requested a review from QuantumExplorer as a code owner May 26, 2024 15:40
@shumkov shumkov changed the title perf(dapi): replace getMnListDiff with steaming endpoint perf(dapi): replace getMnListDiff with a steaming endpoint May 26, 2024
@shumkov shumkov changed the title perf(dapi): replace getMnListDiff with a steaming endpoint perf(dapi): replace getMnListDiff with a streaming endpoint May 26, 2024
@shumkov shumkov changed the title perf(dapi): replace getMnListDiff with a streaming endpoint perf(dapi): replace getMnListDiff with a streaming endpoint May 28, 2024
@thephez thephez added the dapi-endpoint DAPI endpoint addition or modification label May 29, 2024
pshenmic
pshenmic previously approved these changes May 30, 2024
shumkov added 2 commits May 30, 2024 18:15
# Conflicts:
#	packages/dapi-grpc/clients/core/v0/java/org/dash/platform/dapi/v0/CoreGrpc.java
#	packages/dapi-grpc/clients/core/v0/python/core_pb2.py
@shumkov shumkov changed the title perf(dapi): replace getMnListDiff with a streaming endpoint perf(dapi)!: replace getMnListDiff with a streaming endpoint Jun 12, 2024
@shumkov shumkov requested a review from pshenmic June 12, 2024 07:31
@shumkov shumkov merged commit 2c9368a into v1.0-dev Jun 12, 2024
125 checks passed
@shumkov shumkov deleted the feat/dapi/mnlist-stream branch June 12, 2024 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dapi-endpoint DAPI endpoint addition or modification
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants