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

Modify the key format of node in DB to a sequential integer ID instead of the hash value. #592

Closed
2 of 3 tasks
cool-develope opened this issue Oct 18, 2022 · 4 comments
Closed
2 of 3 tasks
Assignees

Comments

@cool-develope
Copy link
Collaborator

cool-develope commented Oct 18, 2022

Context

As we discussed in #571, I am introducing the nonce mechanism here.

  • add nodeKey field to replace the key of a node in DB
  • replace a key in DB from node.hash to nodeKey
  • investigate the possibility of removing version in the node structure

Design Decision

  • immutable tree structure
type ImmutableTree struct {
	root                   *Node
	ndb                    *nodeDB
	version                int64
	nonce                  int64             // new field to track the current ID
	skipFastStorageUpgrade bool
}
  • node structure
type Node struct {
	key           []byte
	value         []byte
	hash          []byte

	leftHash      []byte        
	rightHash     []byte    

	nodeKey       int64         // new field which reflects the current node key
	leftNodeKey   int64       // new field
	rightNodeKey  int64      // new field

	version       int64           // possible to remove ???

	size          int64
	leftNode      *Node
	rightNode     *Node
	subtreeHeight int8
	persisted     bool
}
@tac0turtle
Copy link
Member

Before the final merge we should have an adr on the chnage

@cool-develope
Copy link
Collaborator Author

Before the final merge we should have an adr on the chnage

Yeah, I will prepare the adr when finishing all subtasks.

@catShaark
Copy link
Contributor

I don't think we should remove leftHash and rightHash.
How can I collab with you on this ? I already had the code with the changes mentions here, I've modified methods like balance, delete, save branch ..... so that their logic matches with the new node struct, node saving mechanism.

@cool-develope
Copy link
Collaborator Author

@catShaark don't mind, please keep going your way. We'd like to compare the benchmark results of the two methods.

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

No branches or pull requests

3 participants