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

[Cleanup] Initial documentation improvements and code cleanup #8

Merged
merged 35 commits into from
Jun 1, 2023

Conversation

h5law
Copy link
Collaborator

@h5law h5law commented May 25, 2023

Overview

This PR addresses the lack of documentation in the repo by adding some details to the README.md file and adds some more godoc comments throughout the codebase.

The workflow files have been updated to a use go version 1.18 and have been updated to fully test the repo and produce code coverage reports and check against linters.

The legacy fuzzing has been removed and instead now uses go native fuzzing, the fuzzing tests remain the same and can be improved upon in a separate PR. The oss-fuzz build script has been removed until this repo is on oss-fuzz a new script will not be made.

Additionally linter errors have been addressed.

Issue

Fixes #7

Additional testing enhancements will be covered in a separate PR

Checklist

  • Update any relevant README(s)
  • Add or update any relevant or supporting mermaid diagrams
  • Task specific tests or benchmarks: go test ...
  • New tests or benchmarks: go test ...
  • All tests: go test -v

@h5law h5law added the documentation Improvements or additions to documentation label May 25, 2023
@h5law h5law self-assigned this May 25, 2023
@reviewpad reviewpad bot requested a review from Olshansk May 25, 2023 12:04
@reviewpad reviewpad bot added medium Pull request is medium waiting-for-review This PR is currently waiting to be reviewed and removed documentation Improvements or additions to documentation labels May 25, 2023
@reviewpad reviewpad bot added large Pull request is large and removed medium Pull request is medium labels May 25, 2023
@pokt-network pokt-network deleted a comment from reviewpad bot May 25, 2023
@pokt-network pokt-network deleted a comment from reviewpad bot May 25, 2023
@pokt-network pokt-network deleted a comment from reviewpad bot May 25, 2023
@pokt-network pokt-network deleted a comment from reviewpad bot May 25, 2023
@pokt-network pokt-network deleted a comment from reviewpad bot May 25, 2023
@reviewpad
Copy link

reviewpad bot commented May 25, 2023

Reviewpad Report (Reviewpad ran in dry-run mode because configuration has changed)

📜 Executed actions

$removeLabel("small")
$removeLabel("medium")
$addLabel("large")
$removeLabel("documentation")
$removeLabel("dependencies")

fuzz_test.go Show resolved Hide resolved
fuzz_test.go Show resolved Hide resolved
fuzz_test.go Outdated Show resolved Hide resolved
fuzz_test.go Show resolved Hide resolved
fuzz_test.go Outdated Show resolved Hide resolved
fuzz_test.go Show resolved Hide resolved
fuzz_test.go Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented May 26, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (5c4037e) 84.53% compared to head (0931fa5) 84.53%.

❗ Current head 0931fa5 differs from pull request most recent head 86b4235. Consider uploading reports for the commit 86b4235 to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##             main       #8   +/-   ##
=======================================
  Coverage   84.53%   84.53%           
=======================================
  Files           8        8           
  Lines         776      776           
=======================================
  Hits          656      656           
  Misses         85       85           
  Partials       35       35           
Impacted Files Coverage Δ
hasher.go 100.00% <ø> (ø)
mapstore.go 90.47% <ø> (ø)
options.go 50.00% <ø> (ø)
smt.go 80.91% <ø> (ø)
types.go 87.23% <ø> (ø)
smt_testutil.go 61.70% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

.github/workflows/test.yml Outdated Show resolved Hide resolved
README.md Show resolved Hide resolved
@@ -12,6 +12,7 @@ const (
var (
defaultValue []byte = nil

// ErrKeyNotPresent is returned when a key is not present in the tree.
ErrKeyNotPresent = errors.New("key already empty")
Copy link
Member

Choose a reason for hiding this comment

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

I feel like "key already empty" should be an error for trying to delete an unavailable leaf. ErrKeyNotPresent could also be used when we try to retrieve something non-existent, so it feels like we're conflating a couple things.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So this error is actually only used in the Delete function as if we try to get a key that's not set it returns an empty value - bc all keys are technically set but most are just empty.

smt.go Outdated Show resolved Hide resolved
@@ -6,8 +6,8 @@ import (
)

var (
_ treeNode = &innerNode{}
_ treeNode = &leafNode{}
_ treeNode = (*innerNode)(nil)
Copy link
Member

Choose a reason for hiding this comment

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

Was this a recommendation of the linter?

I'm personally a bigger fan of the previous approach, or potentially using var _ treeNode = new(innerNode) instead

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I actually thought about this a lot and went into the golang discord and this is the idiomatic go way to do this.

There is potentially some issues around the other way linked here but it is unclear if this affects this specific use case.

README.md Show resolved Hide resolved
README.md Show resolved Hide resolved
fuzz_test.go Outdated Show resolved Hide resolved
fuzz_test.go Outdated Show resolved Hide resolved
fuzz_test.go Show resolved Hide resolved
@h5law h5law requested a review from Olshansk May 30, 2023 22:58
README.md Show resolved Hide resolved
@h5law h5law requested a review from Olshansk May 31, 2023 08:56
Copy link
Member

@Olshansk Olshansk left a comment

Choose a reason for hiding this comment

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

Let's keep iterating (merkle sum, radix tree, visualization tooling etc...) and improving the docs, but this, as is, is already really solid work.

Here's to moving the industry forward 🥂

README.md Outdated Show resolved Hide resolved
@@ -0,0 +1,65 @@
<!-- REMOVE this comment block after following the instructions
Copy link
Member

Choose a reason for hiding this comment

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

I realize the urge to throw small things like this into larger PRs, but do try to separate it in the future. nbd this time


The different nodes types described above make the tree have a structure similar to the following:

```mermaid
Copy link
Member

Choose a reason for hiding this comment

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

I think you made really good progress on this, but there is still a lot of opportunity to improve it so it's easier for the reader to understand & interpret. Similar to what the JMT and Relay Mining Paper do. For example, by showing (k, v) = (a, b) or path=0b001 or path_bounds=....

In either case, the visualizer we build might do this automatically for us in the future (we can just have a python structure to mermaid converter) so not a blocker for now.

Screenshot 2023-05-31 at 6 29 02 PM

Screenshot 2023-05-31 at 6 25 14 PM

https://developers.diem.com/papers/jellyfish-merkle-tree/2021-01-14.pdf
https://arxiv.org/pdf/2305.10672.pdf

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have added an interim diagram before we can have a more detailed one to show the paths of different nodes

README.md Outdated Show resolved Hide resolved

_Note_: This diagram is not entirely accurate regarding the process of creating a leaf node, but is a good representation of the process.

```mermaid
Copy link
Member

Choose a reason for hiding this comment

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

Amazing diagram! 👏

h5law and others added 2 commits June 1, 2023 09:59
@h5law h5law merged commit cc555d9 into main Jun 1, 2023
@h5law h5law deleted the documentation_cleanup branch June 1, 2023 10:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
large Pull request is large waiting-for-review This PR is currently waiting to be reviewed
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[Code Health] Improve the documentation, testing and overall health of the repo
3 participants