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

Implement set reconciliation based sync (syncv2) #5769

Closed
wants to merge 80 commits into from
Closed

Conversation

ivan4th
Copy link
Contributor

@ivan4th ivan4th commented Mar 24, 2024

Motivation

Existing sync is causing a lot of resource usage, including memory consumption and network traffic, and can't replace gossip which can also be unreliable at times.

Description

This implements the new sync protocol as described here.
The algorithm is based on Range-Based Set Reconciliation paper by Aljoscha Meyer and also loosely based on SREP: Out-Of-Band Sync of Transaction Pools for Large-Scale Blockchains paper by Novak Boškov, Sevval Simsek, Ari Trachtenberg, and David Starobinski.

Test Plan

Add systests that verify new sync.
Verify on testnet, then on mainnet.

TODO

  • Explain motivation or link existing issue(s)
  • Sync implementation based on red-black monoid tree
  • P2P wire protocol for sync
  • Implement SREP-like multi-peer sync
  • Make code more efficient by getting rid of excess monoid abstraction
  • Implement syncv2 for ATXs. This may include adding an untrusted LayerID field to ATXs to make sync more efficient
  • Implement SQLite-based "pre-balanced" monoid tree for old data to reduce memory consumption
  • Harden the protocol by enforcing communication limits
  • Consider replacing red-black monoid tree with a BTree so it can also be used for atxsdata
  • Implement sync for other object types
  • Test changes and document test plan
  • Update documentation as needed
  • Update changelog as needed

Copy link

codecov bot commented Mar 24, 2024

Codecov Report

Attention: Patch coverage is 81.49957% with 644 lines in your changes missing coverage. Please review.

Project coverage is 81.7%. Comparing base (4ab0d09) to head (1d7f9a7).
Report is 15 commits behind head on develop.

Files with missing lines Patch % Lines
sync2/hashsync/rangesync.go 67.8% 101 Missing and 55 partials ⚠️
sync2/dbsync/fptree.go 83.8% 81 Missing and 28 partials ⚠️
sync2/hashsync/sync_tree.go 82.6% 61 Missing and 20 partials ⚠️
sync2/dbsync/dbitemstore.go 74.2% 30 Missing and 23 partials ⚠️
sync2/hashsync/handler.go 80.3% 23 Missing and 20 partials ⚠️
sync2/dbsync/dbiter.go 80.8% 27 Missing and 13 partials ⚠️
sync2/hashsync/split_sync.go 78.8% 18 Missing and 8 partials ⚠️
sync2/hashsync/sync_tree_store.go 72.8% 16 Missing and 9 partials ⚠️
sync2/dbsync/syncedtable.go 92.0% 9 Missing and 6 partials ⚠️
sync2/hashsync/log.go 59.4% 15 Missing ⚠️
... and 11 more
Additional details and impacted files
@@            Coverage Diff            @@
##           develop   #5769     +/-   ##
=========================================
- Coverage     81.7%   81.7%   -0.1%     
=========================================
  Files          312     334     +22     
  Lines        34625   38076   +3451     
=========================================
+ Hits         28306   31127   +2821     
- Misses        4480    4908    +428     
- Partials      1839    2041    +202     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mathcrypto
Copy link

Did we agree already on adding the LayerID field to ATXs? @poszu @ivan4th. ATXs should only include what's need to be there

@ivan4th
Copy link
Contributor Author

ivan4th commented May 6, 2024

@mathcrypto the discussion was not finished yet, but I restarted it #5785 (comment)

@poszu
Copy link
Contributor

poszu commented Sep 9, 2024

@ivan4th This PR is reaching 14k LoC. Do you think you could start factoring out changes that are already done and could be reviewed to separate PRs?

@ivan4th
Copy link
Contributor Author

ivan4th commented Sep 9, 2024

@poszu that's the plan. Currently debugging ATX sync and this may cause a few more changes in rangesync, but other than that, rangesync together with types subpackages are close to being finished and soon I will split them off into a separate PR

@ivan4th
Copy link
Contributor Author

ivan4th commented Nov 5, 2024

Closed in favor of several other PRs:
#5769 #6404 #6358 #6405 #6406

@ivan4th ivan4th closed this Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants