Skip to content

Commit

Permalink
Merge with main
Browse files Browse the repository at this point in the history
  • Loading branch information
Olshansk committed May 31, 2024
2 parents 3fe0d31 + fea9ecb commit 63643ce
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 25 deletions.
29 changes: 29 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,32 @@ benchmark_smst_ops: ## runs the benchmarks test different operations on the SMS
.PHONY: benchmark_proof_sizes
benchmark_proof_sizes: ## runs the benchmarks test the proof sizes for different sized tries
go test -tags=benchmark -v ./benchmarks -run ProofSizes

###########################
### Release Helpers ###
###########################

# List tags: git tag
# Delete tag locally: git tag -d v1.2.3
# Delete tag remotely: git push --delete origin v1.2.3

.PHONY: tag_bug_fix
tag_bug_fix: ## Tag a new bug fix release (e.g., v1.0.1 -> v1.0.2)
@$(eval LATEST_TAG=$(shell git tag --sort=-v:refname | head -n 1))
@$(eval NEW_TAG=$(shell echo $(LATEST_TAG) | awk -F. -v OFS=. '{ $$NF = sprintf("%d", $$NF + 1); print }'))
@git tag $(NEW_TAG)
@echo "New bug fix version tagged: $(NEW_TAG)"
@echo "Run the following commands to push the new tag:"
@echo " git push origin $(NEW_TAG)"
@echo "And draft a new release at https://github.com/pokt-network/smt/releases/new"


.PHONY: tag_minor_release
tag_minor_release: ## Tag a new minor release (e.g. v1.0.0 -> v1.1.0)
@$(eval LATEST_TAG=$(shell git tag --sort=-v:refname | head -n 1))
@$(eval NEW_TAG=$(shell echo $(LATEST_TAG) | awk -F. '{$$2 += 1; $$3 = 0; print $$1 "." $$2 "." $$3}'))
@git tag $(NEW_TAG)
@echo "New minor release version tagged: $(NEW_TAG)"
@echo "Run the following commands to push the new tag:"
@echo " git push origin $(NEW_TAG)"
@echo "And draft a new release at https://github.com/pokt-network/smt/releases/new"
33 changes: 32 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# smt
# smt <!-- omit in toc -->

[![Tag](https://img.shields.io/github/v/tag/pokt-network/smt.svg?sort=semver)](https://img.shields.io/github/v/tag/pokt-network/smt.svg?sort=semver)
[![GoDoc](https://godoc.org/github.com/pokt-network/smt?status.svg)](https://godoc.org/github.com/pokt-network/smt)
Expand All @@ -13,6 +13,9 @@
- [Documentation](#documentation)
- [Tests](#tests)
- [Benchmarks](#benchmarks)
- [Release Tags](#release-tags)
- [Tagging a new release](#tagging-a-new-release)
- [Push and Release](#push-and-release)

<!-- tocstop -->

Expand Down Expand Up @@ -60,3 +63,31 @@ To view pre-ran results of the entire benchmarking suite see

[jmt whitepaper]: https://developers.diem.com/papers/jellyfish-merkle-tree/2021-01-14.pdf
[libra whitepaper]: https://diem-developers-components.netlify.app/papers/the-diem-blockchain/2020-05-26.pdf

## Release Tags

You can tag and publish a new release by following the instructions bellow.

### Tagging a new release

For a bug fix:

```bash
make tag_bug_fix
```

For a minor release run:

```bash
make tag_minor_release
```

### Push and Release

Then, push the tag to the repository:

```bash
git push origin v<release>
```

Create a release on GitHub with the tag and the release notes [here](https://github.com/pokt-network/smt/releases/new).
53 changes: 31 additions & 22 deletions docs/smt.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,34 @@
# smt <!-- omit in toc -->

- [nodes concatenated hashes.](#nodes-concatenated-hashes) - [Extension Nodes](#extension-nodes) - [Lazy Nodes](#lazy-nodes) - [Lazy Loading](#lazy-loading) - [Visualisations](#visualisations) - [General Trie Structure](#general-trie-structure) - [Lazy Nodes](#lazy-nodes-1)
- [Paths](#paths)
- [Visualisation](#visualisation)
- [Values](#values)
- [Nil values](#nil-values)
- [Hashers \& Digests](#hashers--digests)
- [Hash Function Recommendations](#hash-function-recommendations)
- [Roots](#roots)
- [Proofs](#proofs)
- [Verification](#verification)
- [Closest Proof](#closest-proof)
- [Closest Proof Use Cases](#closest-proof-use-cases)
- [Compression](#compression)
- [Serialisation](#serialisation)
- [Database](#database)
- [Database Submodules](#database-submodules)
- [SimpleMap](#simplemap)
- [Badger](#badger)
- [Data Loss](#data-loss)
- [Sparse Merkle Sum Trie](#sparse-merkle-sum-trie)
- [Overview](#overview)
- [Implementation](#implementation)
- [Leaf Nodes](#leaf-nodes)
- [Inner Nodes](#inner-nodes)
- [Extension Nodes](#extension-nodes)
- [Lazy Nodes](#lazy-nodes)
- [Lazy Loading](#lazy-loading)
- [Visualizations](#visualizations)
- [General Trie Structure](#general-trie-structure)
- [Lazy Nodes](#lazy-nodes-1)
- [Paths](#paths)
- [Visualization](#visualization)
- [Values](#values)
- [Nil values](#nil-values)
- [Hashers \& Digests](#hashers--digests)
- [Hash Function Recommendations](#hash-function-recommendations)
- [Roots](#roots)
- [Proofs](#proofs)
- [Verification](#verification)
- [Closest Proof](#closest-proof)
- [Closest Proof Use Cases](#closest-proof-use-cases)
- [Compression](#compression)
- [Serialisation](#serialisation)
- [Database](#database)
- [Database Submodules](#database-submodules)
- [SimpleMap](#simplemap)
- [Badger](#badger)
- [Data Loss](#data-loss)
- [Sparse Merkle Sum Trie](#sparse-merkle-sum-trie)

## Overview

Expand Down Expand Up @@ -110,7 +119,7 @@ Once the `Commit()` function is called the trie will delete any orphaned nodes
from the database and write the key-value pairs of all the unpersisted leaf
nodes' hashes and their values to the database.

### Visualisations
### Visualizations

The following diagrams are representations of how the trie and its components
can be visualised.
Expand Down Expand Up @@ -209,7 +218,7 @@ Inner nodes do **not** contain a path, as they represent a branch in the trie
and not a path. As such their children, _if they are extension nodes or leaf
nodes_, will hold a path value.

### Visualisation
### Visualization

The following diagram shows how paths are stored in the different nodes of the
trie. In the actual SMT paths are not 8 bit binary strings but are instead the
Expand Down
2 changes: 1 addition & 1 deletion hasher.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func (ph *pathHasher) PathSize() int {
return ph.hasher.Size()
}

// HashValue hashes the data provided using the value hasher
// HashValue hashes the produces a digest of the data provided by the value hasher
func (vh *valueHasher) HashValue(data []byte) []byte {
return vh.digestData(data)
}
Expand Down
2 changes: 1 addition & 1 deletion smt.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func NewSparseMerkleTrie(
options ...TrieSpecOption,
) *SMT {
smt := SMT{
TrieSpec: newTrieSpec(hasher, false),
TrieSpec: NewTrieSpec(hasher, false),

Check failure on line 37 in smt.go

View workflow job for this annotation

GitHub Actions / tests

undefined: NewTrieSpec (typecheck)

Check failure on line 37 in smt.go

View workflow job for this annotation

GitHub Actions / tests

undefined: NewTrieSpec) (typecheck)
nodes: nodes,
}
for _, option := range options {
Expand Down

0 comments on commit 63643ce

Please sign in to comment.