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

core, eth: rework snap sync #564

Conversation

Francesco4203
Copy link
Collaborator

@Francesco4203 Francesco4203 commented Sep 6, 2024

@huyngopt1994
Copy link
Collaborator

	var onSlot func(paths [][]byte, hexpath []byte, leaf []byte, parent common.Hash) error
	var onSlot func(keys [][]byte, path []byte, leaf []byte, parent common.Hash, parentPath []byte) error

The reason behind why we changed from paths to keys and hexpath to path

keys is a tuple of 32 bytes key. path is the hex format nibbles. Just want to make it less-ambiguous. 

The keys []byte will convert to hex format nibbles via this function

func keybytesToHex(str []byte) []byte {
	l := len(str)*2 + 1
	var nibbles = make([]byte, l)
	for i, b := range str {
		nibbles[i*2] = b / 16
		nibbles[i*2+1] = b % 16
	}
	nibbles[l-1] = 16
	return nibbles
}

}

// NodeSyncResult is a response with requested trie node along with its node path.
type NodeSyncResult struct {
Copy link
Collaborator

@huyngopt1994 huyngopt1994 Sep 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

split request logic into node and code, same with SyncResult


if _, present := codeTasks[hash]; present {
err := s.sched.ProcessCode(trie.CodeSyncResult{
Hash: hash,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the previous logic.

err := s.sched.Process(res)

They will forward res to Process function , in the new logic, we need to split into handle either ProcessCode or ProcessNode. Could u explain a little the condition check here for choosing which kind of processing in sched.

Copy link
Collaborator Author

@Francesco4203 Francesco4203 Sep 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the requests list is also now divided into nodeReqs and codeReqs, we use ProcessNode for each request taking from nodeReqs and ProcessCode for each request taking from codeReqs

core, eth, les, trie: rework snap sync
@huyngopt1994
Copy link
Collaborator

LGTM, let merge and retest again

@huyngopt1994 huyngopt1994 merged commit 1b91fce into axieinfinity:path-base-implementing Sep 11, 2024
1 check passed
Francesco4203 added a commit to Francesco4203/ronin that referenced this pull request Sep 16, 2024
core, eth, les, trie: rework snap sync

Co-authored-by: rjl493456442 <[email protected]>
huyngopt1994 pushed a commit that referenced this pull request Sep 17, 2024
core, eth, les, trie: rework snap sync

Co-authored-by: rjl493456442 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants