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

trie: add trie db wrapper; refactor trienode #588

Conversation

Francesco4203
Copy link
Contributor

@Francesco4203 Francesco4203 commented Sep 27, 2024

References:

Changes:

  • Add wrapper for database since later, we will have another database for path-based. Note that the common features such as cache, preimage,... are in the wrapper interface.
  • Move nodeset to trienode/node
  • Adjust tests: add scheme to tests for later testing on path-based
  • Remove callback in db.Commit() since it is not used (ref all: port changes from pbss PR ethereum/go-ethereum#26637)

@Francesco4203 Francesco4203 force-pushed the rework-trie-nodeset branch 2 times, most recently from a43b785 to 084eac9 Compare September 27, 2024 08:56
@Francesco4203 Francesco4203 changed the title [WIP] trie: refactor db & trienode trie: add trie db wrapper; refactor trienode Sep 27, 2024
@huyngopt1994
Copy link
Collaborator

noted, it will split trie/database.go -> into trie/triedb/<hashdb/pathdb> structure.

// Node is a wrapper which contains the encoded blob of the trie node and its
// unique hash identifier. It is general enough that can be used to represent
// trie nodes corresponding to different trie implementations.
type Node struct {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Rename from memoryNode-> Node

trie/trienode/node.go Outdated Show resolved Hide resolved
}

// AddLeaf adds the provided leaf node into set.
func (set *NodeSet) AddLeaf(parent common.Hash, blob []byte) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

before, they init leaf obj and pass directly here.

func (set *NodeSet) addLeaf(leaf *leaf) {
   set.leaves = append(set.leaves, leaf)
}

}
//} else {
Copy link
Collaborator

Choose a reason for hiding this comment

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

hm Why we comment here. ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It will be later enabled for path based scheme

trie: change name WithPrev => NodeWithPrev
rawdb: add schema_test
Copy link
Collaborator

@huyngopt1994 huyngopt1994 left a comment

Choose a reason for hiding this comment

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

LGTM

@huyngopt1994 huyngopt1994 merged commit 4a72920 into axieinfinity:path-base-implementing Oct 1, 2024
1 check passed
Francesco4203 added a commit that referenced this pull request Oct 17, 2024
* trie: add wrapper for database

* trie: refactor trie node

* all: fix test

* rawdb, trie: fix comment

trie: change name WithPrev => NodeWithPrev
rawdb: add schema_test
huyngopt1994 pushed a commit that referenced this pull request Oct 25, 2024
* trie: add wrapper for database

* trie: refactor trie node

* all: fix test

* rawdb, trie: fix comment

trie: change name WithPrev => NodeWithPrev
rawdb: add schema_test
huyngopt1994 pushed a commit that referenced this pull request Nov 21, 2024
* trie: add wrapper for database

* trie: refactor trie node

* all: fix test

* rawdb, trie: fix comment

trie: change name WithPrev => NodeWithPrev
rawdb: add schema_test
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.

2 participants