-
Notifications
You must be signed in to change notification settings - Fork 52
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
Code Refactoring #78
Comments
@pipermerriam would you like to add something more on top of this, in terms of specs? |
This generally looks good and you're 👍 to start on this. |
We have been talking about a benchmarking refactor in py-evm, see ethereum/py-evm#1306 This could be a good time to try that out. Using the new proposed structure should be an improvement, but if it becomes a sticking point or a drag, just go back to the current way. No need to tie the two issues together. |
@carver thankyou for the reference, will take a look. |
@pipermerriam I have the basic prototype ready (cleanly designed), which just takes the key as a |
It'd be helpful to see some code if you have it. |
@pipermerriam @carver After going through the yellow paper and a few examples, I have came up with the following neater version of the insert_child(key, value)The main idea here is that, when we want to insert a key and it’s corresponding value in the trie, we call the LeafNode
BranchNode
ExtensionNode
get_value(key)LeafNode
BranchNode
ExtensionNode
delete_value(key)LeafNode
BranchNode
ExtensionNode
|
@pipermerriam @carver I have tried my level best to be clear with the implementation followed. Please let me know if any part of it is unclear (or) if there is something that I'm missing out. |
I believe that the above approach eliminates the need of using a |
@Bhargavasomu my memory of the algorithm is sufficiently foggy that I don't recall if the nibbles terminator is a protocol thing or an implementation thing. If it's just an implementation bit, I have no problem removing it. If it is protocol, I don't believe we can remove it. In general, your plan/structure sounds fine, but I'll only really know once there is code to review. 👍 to move forward with this. |
I just saw this: #79 👀 |
What was wrong?
The whole code base is a bit hard to read and could be structured better.
How can it be fixed?
The code base can be refactored with the following improvements
Leaf Nodes
,Branch Nodes
,Extension Nodes
which in turn inherit a common classBaseNode
. The classBaseNode
should contain the followingLeaf
orBranch
orExtension
)Extension
andLeaf
nodes. List of size 16 forBranch
nodes).value
contained in the node (If has nothing, thenNull
)get_all_children
methodEncode
andDecode
methodsparse_node
methodBaseTrie
class should be implemented from which theBinaryTrie
and theHexaryTrie
should be implemented.py-evm
)The text was updated successfully, but these errors were encountered: