-
Notifications
You must be signed in to change notification settings - Fork 69
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
refactor: deobfuscate dragonberry #383
Conversation
r := bytes.NewReader(op.GetPrefix()) | ||
|
||
values := []int64{} | ||
for i := 0; i < 3; i++ { |
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 decided to remove the for loop for readability, so each height, size, and version could have a var name rather than an index
if err != nil { | ||
return err | ||
} | ||
if int(height) < 0 || int(height) < layerNum { |
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.
previous check: if int(values[0]) < b {
moved here in int(height) < layerNum
// the height, size, and version of the IAVL tree. Each varint must be a bounded value. | ||
// In addition, the remaining bytes are validated to ensure they correspond to the correct | ||
// length. | ||
func validateIavlOps(op opType, layerNum int) error { |
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.
b
-> layerNum
open to other naming suggestions
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.
layerNum
is good to me, maybe we can indicate in godoc that it corresponds to tree depth
} | ||
|
||
// grab the length of the remainder of the prefix | ||
remLen := r.Len() |
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.
r2
-> remLen
open to other naming suggestions!
// when the child comes from the left, the suffix if filled in | ||
// prefix: height | size | version | length byte (1 remainder) | ||
// | ||
// when the child comes from the right, the suffix is empty | ||
// prefix: height | size | version | length byte | 32 byte hash | next length byte (34 remainder) |
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.
thanks @damiannolan for this!
cc @ValarDragon (if you want to take a peek 🙂 ) |
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.
Beautiful, thank you @colin-axner! So much easier to grok! ❤️
Co-authored-by: Damian Nolan <[email protected]>
…23 into colin/deobfuscate-dragonberry
love it |
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.
Amazing!! Thanks @colin-axner
Thank you @damiannolan for the assistance!