Skip to content

Commit

Permalink
chore: rename master to main (#249)
Browse files Browse the repository at this point in the history
Closes #171
  • Loading branch information
rootulp authored Apr 17, 2024
1 parent a81c073 commit eb927ae
Show file tree
Hide file tree
Showing 8 changed files with 200 additions and 200 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Go

on:
push:
branches: [ master ]
branches: [ main ]
pull_request:

jobs:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ on:
pull_request:
push:
branches:
- master
- main
jobs:
# Runs golangci-lint over the nmt repository
# This workflow is run on every pull request and push to master
# This workflow is run on every pull request and push to main
# The `golangci` job will pass without running if no *.{go, mod, sum} files have been modified.
golangci:
name: golangci-lint
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

![Go version](https://img.shields.io/badge/go-1.21-blue.svg)
[![Go Reference](https://pkg.go.dev/badge/github.com/celestiaorg/nmt.svg)](https://pkg.go.dev/github.com/celestiaorg/nmt)
![golangci-lint](https://github.com/celestiaorg/nmt/workflows/golangci-lint/badge.svg?branch=master)
![golangci-lint](https://github.com/celestiaorg/nmt/workflows/golangci-lint/badge.svg?branch=main)
![Go](https://github.com/celestiaorg/nmt/workflows/Go/badge.svg)
![codecov.io](https://codecov.io/github/celestiaorg/nmt/coverage.svg?branch=master)
![codecov.io](https://codecov.io/github/celestiaorg/nmt/coverage.svg?branch=main)

A Namespaced Merkle Tree is
> [...] an ordered Merkle tree that uses a modified hash function
Expand Down
6 changes: 3 additions & 3 deletions docs/nmt-lib.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ idSize := tree.NamespaceSize() // outputs 1
If the NMT is configured with `IgnoreMaxNamespace` set to true (the flag is explained [here](#nmt-initialization-and-configuration)), then the calculation of the namespace ID range of non-leaf nodes in the [namespace hash function](./spec/nmt.md#namespaced-hash) will change slightly.
That is, if the right child of a node is entirely filled with leaves with the maximum possible namespace `maxPossibleNamespace`, i.e., its minimum and maximum namespace are equal to the `maxPossibleNamespace`, then the right child is excluded from the calculation of the namespace ID range of the parent node, and the parent node inherits the namespace range of the left child.
In the preceding code example with the ID size of `1` byte, the value of `maxPossibleNamespace` is $2^8-1 = 0xFF$.
Concretely, consider a node `n` with children `l` and `r`. If `r.minNs` and `r.maxNs` are both equal to `maxPossibleNamespace` (indicating that it represents the root of a subtree whose leaves all have the namespace ID of `maxPossibleNamespace`), then the namespace ID range of `n` is set to the namespace range of `l`, i.e., `n.MinNs = l.MinNs` and `n.MaxNs = l.MaxNs`.
Concretely, consider a node `n` with children `l` and `r`. If `r.minNs` and `r.maxNs` are both equal to `maxPossibleNamespace` (indicating that it represents the root of a subtree whose leaves all have the namespace ID of `maxPossibleNamespace`), then the namespace ID range of `n` is set to the namespace range of `l`, i.e., `n.MinNs = l.MinNs` and `n.MaxNs = l.MaxNs`.
Otherwise, the namespace ID range of `n` is set as normal i.e., `n.minNs = min(l.minNs, r.minNs)` and `n.maxNs = max(l.maxNs, r.maxNs)`.

Note that the `IgnoreMaxNamespace` flag is Celestia-specific and is motivated by the fact that half of the data items in the NMT are associated with reserved namespace IDs (i.e., the highest possible value within the ID size) and do not need to be queried using their namespace IDs.
Expand Down Expand Up @@ -80,7 +80,7 @@ d2 := namespace.PrefixedData(append(namespace.ID{1}, []byte("leaf_2")...))
if err := tree.Push(d2); err != nil {
// something went wrong
}
d3 := namespace.PrefixedData(append(namespace.ID{3}, []byte("leaf_3")...))
d3 := namespace.PrefixedData(append(namespace.ID{3}, []byte("leaf_3")...))
if err := tree.Push(d3); err != nil {
// something went wrong
}
Expand Down Expand Up @@ -186,7 +186,7 @@ In the example given earlier, each node is `34` bytes in length and takes the fo

## Verify Namespace Proof

The correctness of a namespace `Proof` for a specific namespace ID `nID` can be verified using the [`VerifyNamespace`](https://github.com/celestiaorg/nmt/blob/master/proof.go) method.
The correctness of a namespace `Proof` for a specific namespace ID `nID` can be verified using the [`VerifyNamespace`](https://github.com/celestiaorg/nmt/blob/main/proof.go) method.

```go
func (proof Proof) VerifyNamespace(h hash.Hash, nID namespace.ID, leaves [][]byte, root []byte) bool
Expand Down
4 changes: 2 additions & 2 deletions nmt.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Package nmt contains an NMT implementation.
// The specifications can be found in https://github.com/celestiaorg/nmt/blob/master/docs/spec/nmt.md.
// The specifications can be found in https://github.com/celestiaorg/nmt/blob/main/docs/spec/nmt.md.
package nmt

import (
Expand Down Expand Up @@ -69,7 +69,7 @@ func NamespaceIDSize(size int) Option {
// IgnoreMaxNamespace sets whether the largest possible namespace.ID MAX_NID
// should be 'ignored'. If set to true, this allows for shorter proofs in
// particular use-cases. E.g., see:
// https://github.com/celestiaorg/celestiaorg-specs/blob/master/specs/data_structures.md#namespace-merkle-tree
// https://github.com/celestiaorg/celestiaorg-specs/blob/main/specs/data_structures.md#namespace-merkle-tree
// Defaults to true.
func IgnoreMaxNamespace(ignore bool) Option {
return func(opts *Options) {
Expand Down
8 changes: 4 additions & 4 deletions nmt_quint_model/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ is necessary.
translates them to function calls.)
The generation of the tests happens through simulation.
In that sense, it is similar to the existing tests
[fuzz_test.go](https://github.com/celestiaorg/nmt/blob/master/fuzz_test.go),
[fuzz_test.go](https://github.com/celestiaorg/nmt/blob/main/fuzz_test.go),
except that it also adds corruption of the data.
- Having specifications written in Quint makes it possible to change
tests/specs quickly:
Expand Down Expand Up @@ -110,13 +110,13 @@ verifyInclusionProof(proofZero, c_root, 0, [{ value: ("data", 0), namespaceId: 2
import nmtProofVerification.*
// runs the initialization action
init
init
// runs one step of the model
step
step
// runs another step of the model
step
step
```

After getting acquainted with all the operators,
Expand Down
Loading

0 comments on commit eb927ae

Please sign in to comment.