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

[Snap Syncing] - Create Function to snap Sync for further expansion #1399

Closed
mibuono opened this issue Feb 8, 2024 · 6 comments
Closed

[Snap Syncing] - Create Function to snap Sync for further expansion #1399

mibuono opened this issue Feb 8, 2024 · 6 comments
Assignees

Comments

@mibuono
Copy link

mibuono commented Feb 8, 2024

Create a function to snap sync 500 prime blocks back. This function will be used in issue #1398 to eventually change to snapping 3 interlinks back.

@mibuono mibuono changed the title [Snap Syncing] [Snap Syncing] - Create Function to snap Sync for further expansion Feb 8, 2024
@gameofpointers
Copy link
Contributor

geth has implemented snapsync, by downloading trie nodes, so looking at downloader.go, handlers.go to understand how the downloading is done is a good start in implementing the feature

@alejoacosta74
Copy link
Contributor

Guidelines provided by @gameofpointers

  1. Every Broadcast will send the block through the WriteBlock() in core.go, So for Prime you need to trigger a startSnapSync in Zones based on the criteria
  2. For now the criteria can be number of blocks behind
  3. Write a subclient method to recursively call all the subclients until we reach zone and for now pick the Zone number in Zone to send a start snap sync message to quai/handler.go
  4. To do this you need a feed in core.go and send the block number there
  5. Create a subscription in core that listens to that feed and create a go routine in quai/handler.go that listens to the start snap sync message and waits for a message to be sent in the feed (similar to all the other go routines in quai/handler)
  6. Here is when you start the snap sync process, Request for the Block by that number and then get the root for the block and then keep asking for child node similar to the downloader.go snapsync

@alejoacosta74
Copy link
Contributor

PR: dominant-strategies#95

@alejoacosta74
Copy link
Contributor

PR

#1507

Current testing status

Testing logs:

Request (snap sync starter)

DEBUG  [03-11|20:43:55.226] src: quai/handler.go:194 - func: quai.(*handler).startSnapSync :  starting snapshot sync for location cyprus1 and block 5
TRACE  [03-11|20:43:55.226] src: downloader/downloader.go:35 - func: downloader.(*Downloader).StartSnapSync :  Requesting block 5 for location cyprus1
TRACE  [03-11|20:43:55.226] src: node/api.go:122 - func: node.(*P2PNode).requestFromPeers.func1.1 :  Requesting the data from peer                 data=5 dataType="*types.Block" location=cyprus1 peerId=12D3KooWG7k4t3DjoQbpA6xmc1v3PET4QUF77SJiP3N1YPyDSAaM
TRACE  [03-11|20:44:00.215] src: downloader/downloader.go:40 - func: downloader.(*Downloader).StartSnapSync :  fetched block 5 for location cyprus1 (hash 0x000027da126f6d5b01f99eb13b2254dc1b152955d64b9088df4f6f6fa804531b)
TRACE  [03-11|20:44:00.215] src: downloader/downloader.go:42 - func: downloader.(*Downloader).StartSnapSync :  Fetching state trie for EVM root 0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421 and location cyprus1
TRACE  [03-11|20:44:00.215] src: downloader/fetcher.go:140 - func: downloader.(*fetcher).fetchTrieNode :  fetching trie node 0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421 from block 0x000027da126f6d5b01f99eb13b2254dc1b152955d64b9088df4f6f6fa804531b and location cyprus1
TRACE  [03-11|20:44:00.215] src: downloader/fetcher.go:145 - func: downloader.(*fetcher).fetchTrieNode :  sending trie node request for 0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421 (location cyprus1) - retry 0

Responder

DEBUG  [03-11|20:44:00.404] src: protocol/protocol.go:98 - func: protocol.handleRequest :  Looking hash for block 5 and location cyprus1 
DEBUG  [03-11|20:44:00.404] src: protocol/protocol.go:105 - func: protocol.handleRequest :  Found hash for block 5 and location: cyprus1%!(EXTRA *common.Hash=0x000027da126f6d5b01f99eb13b2254dc1b152955d64b9088df4f6f6fa804531b) 
TRACE  [03-11|20:44:00.404] src: protocol/handlers.go:17 - func: protocol.handleBlockRequest :  looking up block 0x000027da126f6d5b01f99eb13b2254dc1b152955d64b9088df4f6f6fa804531b for location cyprus1 
DEBUG  [03-11|20:44:00.404] src: protocol/handlers.go:24 - func: protocol.handleBlockRequest :  block found 0x000027da126f6d5b01f99eb13b2254dc1b152955d64b9088df4f6f6fa804531b for location cyprus1 
TRACE  [03-11|20:44:00.405] src: protocol/protocol.go:51 - func: protocol.QuaiProtocolHandler :  Sent block to peer                            blockHash=0x000027da126f6d5b01f99eb13b2254dc1b152955d64b9088df4f6f6fa804531b peer=12D3KooWHMTAw93GM1kbza5DMkecy2nq2vet9rmcL81yH9nnRj8y
DEBUG  [03-11|20:44:00.419] src: node/api.go:43 - func: node.(*P2PNode).Start.func1 :  Received request by hash to handle            decodedType="{}" hash=0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421 location="[0 0]" peer=12D3KooWHMTAw93GM1kbza5DMkecy2nq2vet9rmcL81yH9nnRj8y requestID=1040333459
TRACE  [03-11|20:44:00.419] src: protocol/handlers.go:91 - func: protocol.handleTrieNodeRequest :  looking up trie node 0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421 from location cyprus1 
TRACE  [03-11|20:44:00.419] src: quai/p2p_backend.go:170 - func: quai.(*QuaiBackend).LookupTrieNode :  Looking up trie node 0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421 at location cyprus1 
TRACE  [03-11|20:44:00.419] src: core/bodydb.go:225 - func: core.(*BodyDb).GetTrieNodeByHash :  Looking up trie node 0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421 at location cyprus1 
TRACE  [03-11|20:44:00.420] src: core/bodydb.go:226 - func: core.(*BodyDb).GetTrieNodeByHash :  Processing state: true:                      
ERROR  [03-11|20:44:00.420] src: node/api.go:43 - func: node.(*P2PNode).Start.func1 :  error handling trie node request              err="error getting trie node for hash 0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421: not found"

@alejoacosta74
Copy link
Contributor

Diagram of current implementation

Image

@alejoacosta74
Copy link
Contributor

PR: #1527

@alejoacosta74 alejoacosta74 linked a pull request Mar 22, 2024 that will close this issue
@mibuono mibuono closed this as completed Apr 23, 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 a pull request may close this issue.

3 participants