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

refactor: deobfuscate dragonberry #383

Merged
merged 15 commits into from
Oct 21, 2024
Merged

Conversation

colin-axner
Copy link
Contributor

@colin-axner colin-axner commented Oct 10, 2024

Thank you @damiannolan for the assistance!

r := bytes.NewReader(op.GetPrefix())

values := []int64{}
for i := 0; i < 3; i++ {
Copy link
Contributor Author

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 {
Copy link
Contributor Author

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 {
Copy link
Contributor Author

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

Copy link
Contributor

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()
Copy link
Contributor Author

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!

go/ops.go Outdated Show resolved Hide resolved
Comment on lines +63 to +67
// 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)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks @damiannolan for this!

@colin-axner colin-axner marked this pull request as ready for review October 14, 2024 12:41
@colin-axner
Copy link
Contributor Author

cc @ValarDragon (if you want to take a peek 🙂 )

Copy link
Contributor

@damiannolan damiannolan left a 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! ❤️

go/ops.go Outdated Show resolved Hide resolved
@faddat
Copy link
Contributor

faddat commented Oct 19, 2024

love it

Copy link
Member

@AdityaSripal AdityaSripal left a 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

go/ops_test.go Outdated Show resolved Hide resolved
@colin-axner colin-axner merged commit 5bb1b54 into master Oct 21, 2024
6 checks passed
@colin-axner colin-axner deleted the colin/deobfuscate-dragonberry branch October 21, 2024 08:36
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.

4 participants