-
Notifications
You must be signed in to change notification settings - Fork 141
Use hash writer for aristo computeKey #3572
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
base: master
Are you sure you want to change the base?
Conversation
computeKey
…ent computing branchKey multiple times within a single call.
computeKey
computeKey
computeKey
w.startList(2) | ||
w.append(pfx.toHexPrefix(isLeaf = true).data()) | ||
w.wrapEncoding(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doesn't this call to wrapEnconding
depend on leafData
being of a particular type? if yes, why use auto
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about wrapEncoding
but the reason I changed this line was that we are passing a type account or slot and don't need to pass in a block of statements. Perhaps it would be better to make it even more strict and use Account | UInt256
as the type.
|
||
template encodeBranch(w: var RlpWriter, vtx: VertexRef, subKeyForN: untyped): HashKey = | ||
template encodeLeaf(w: var AristoTrieWriter, pfx: NibblesBuf, leafData: auto): HashKey = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
multiple evaluations of leafData
- auto
or untyped
doesn't really matter in this context, they behave the same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes this change wasn't related to reducing the evaluations. I just wanted to remove the untyped parameter.
@@ -154,7 +154,7 @@ template appendExt(w: var RlpWriter, pfx: NibblesBuf, branchKey: HashKey) = | |||
w.append(pfx.toHexPrefix(isLeaf = false).data()) | |||
w.append(branchKey) | |||
|
|||
template encodeExt(w: var AristoTrieWriter, pfx: NibblesBuf, branchKey: untyped): HashKey = | |||
func encodeExt(w: var AristoTrieWriter, pfx: NibblesBuf, branchKey: HashKey): HashKey = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is the one which reduces the evaluations of branchKey from 2 per call to 1.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the same thing applies to subKeyForN
and leafData
- they need to either be stored in a variable or encodeBranch/encodeLeaf need to be made func
closed duplicate: #3226
fixes: #3164
Uses the rlp hash writer for Aristo DB's
computeKey
implementation