Skip to content

Commit

Permalink
chore: bump NMT to v0.15.0 (#1579)
Browse files Browse the repository at this point in the history
Cherry-pick the following commits to the v0.12.x release branch:
1.
ee84e3d
2.
909a566

Will create v0.12.2 after this merges

---------

Co-authored-by: rene <[email protected]>
  • Loading branch information
rootulp and renaynay authored Mar 31, 2023
1 parent 7e1792b commit 9698a07
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 15 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/celestiaorg/celestia-app
go 1.18

require (
github.com/celestiaorg/nmt v0.14.0
github.com/celestiaorg/nmt v0.15.0
github.com/celestiaorg/quantum-gravity-bridge v1.3.0
github.com/ethereum/go-ethereum v1.10.26
github.com/gogo/protobuf v1.3.3
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ github.com/celestiaorg/cosmos-sdk v1.8.0-sdk-v0.46.7 h1:EADZy33ufskVIy6Rj6jbi3SO
github.com/celestiaorg/cosmos-sdk v1.8.0-sdk-v0.46.7/go.mod h1:vg3Eza9adJJ5Mdx6boz5MpZsZcTZyrfTVYZHyi2zLm4=
github.com/celestiaorg/merkletree v0.0.0-20210714075610-a84dc3ddbbe4 h1:CJdIpo8n5MFP2MwK0gSRcOVlDlFdQJO1p+FqdxYzmvc=
github.com/celestiaorg/merkletree v0.0.0-20210714075610-a84dc3ddbbe4/go.mod h1:fzuHnhzj1pUygGz+1ZkB3uQbEUL4htqCGJ4Qs2LwMZA=
github.com/celestiaorg/nmt v0.14.0 h1:ET1PXBm8f3KHCAB7+sRVMTmvejkpQp6HAQsGLjIRtcY=
github.com/celestiaorg/nmt v0.14.0/go.mod h1:b+pwd9cGTSSYLZnUIQSJl07pusJdFeEvCVsVfSRH9gA=
github.com/celestiaorg/nmt v0.15.0 h1:ID9QlMIeP6WK/iiGcfnYLu2qqVIq0UYe/dc3TVPt6EA=
github.com/celestiaorg/nmt v0.15.0/go.mod h1:GfwIvQPhUakn1modWxJ+rv8dUjJzuXg5H+MLFM1o7nY=
github.com/celestiaorg/quantum-gravity-bridge v1.3.0 h1:9zPIp7w1FWfkPnn16y3S4FpFLnQtS7rm81CUVcHEts0=
github.com/celestiaorg/quantum-gravity-bridge v1.3.0/go.mod h1:6WOajINTDEUXpSj5UZzod16UZ96ZVB/rFNKyM+Mt1gI=
github.com/celestiaorg/rsmt2d v0.8.0 h1:ZUxTCELZCM9zMGKNF3cT+rUqMddXMeiuyleSJPZ3Wn4=
Expand Down
6 changes: 5 additions & 1 deletion pkg/wrapper/nmt_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,11 @@ func (w *ErasuredNamespacedMerkleTree) Push(data []byte) {
// Root fulfills the rsmt.Tree interface by generating and returning the
// underlying NamespaceMerkleTree Root.
func (w *ErasuredNamespacedMerkleTree) Root() []byte {
return w.tree.Root()
root, err := w.tree.Root()
if err != nil {
panic(err)
}
return root
}

func (w *ErasuredNamespacedMerkleTree) Prove(ind int) (nmt.Proof, error) {
Expand Down
12 changes: 10 additions & 2 deletions pkg/wrapper/nmt_wrapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ func TestRootErasuredNamespacedMerkleTree(t *testing.T) {
}
}

assert.NotEqual(t, nmtTree.Root(), tree.Root())
root, err := nmtTree.Root()
assert.NoError(t, err)
assert.NotEqual(t, root, tree.Root())
}

func TestErasureNamespacedMerkleTreePanics(t *testing.T) {
Expand Down Expand Up @@ -113,7 +115,13 @@ func TestErasuredNamespacedMerkleTree(t *testing.T) {
}

assert.Equal(t, tree.Tree(), tree.tree)
assert.Equal(t, tree.Tree().Root(), tree.tree.Root())

publicRoot, err := tree.Tree().Root()
assert.NoError(t, err)

privateRoot, err := tree.tree.Root()
assert.NoError(t, err)
assert.Equal(t, publicRoot, privateRoot)
}

// generateErasuredData produces a slice that is twice as long as it erasures
Expand Down
14 changes: 7 additions & 7 deletions testutil/testnode/full_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ import (
"testing"
"time"

"github.com/celestiaorg/celestia-app/app"
"github.com/celestiaorg/celestia-app/app/encoding"
"github.com/celestiaorg/celestia-app/cmd/celestia-appd/cmd"
"github.com/celestiaorg/celestia-app/testutil/testfactory"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
pruningtypes "github.com/cosmos/cosmos-sdk/pruning/types"
Expand All @@ -29,6 +25,11 @@ import (
"github.com/tendermint/tendermint/proxy"
"github.com/tendermint/tendermint/types"
dbm "github.com/tendermint/tm-db"

"github.com/celestiaorg/celestia-app/app"
"github.com/celestiaorg/celestia-app/app/encoding"
"github.com/celestiaorg/celestia-app/cmd/celestia-appd/cmd"
"github.com/celestiaorg/celestia-app/testutil/testfactory"
)

// New creates a ready to use tendermint node that operates a single validator
Expand All @@ -44,6 +45,7 @@ func New(
supressLog bool,
genState map[string]json.RawMessage,
kr keyring.Keyring,
chainID string,
) (*node.Node, srvtypes.Application, Context, error) {
var logger log.Logger
if supressLog {
Expand All @@ -58,8 +60,6 @@ func New(
return nil, nil, Context{}, err
}

chainID := tmrand.Str(6)

encCfg := encoding.MakeConfig(app.ModuleEncodingRegisters...)

nodeKey, err := p2p.LoadOrGenNodeKey(tmCfg.NodeKeyFile())
Expand Down Expand Up @@ -192,7 +192,7 @@ func DefaultNetwork(t *testing.T, blockTime time.Duration) (cleanup func() error
genState, kr, err := DefaultGenesisState(accounts...)
require.NoError(t, err)

tmNode, app, cctx, err := New(t, DefaultParams(), tmCfg, false, genState, kr)
tmNode, app, cctx, err := New(t, DefaultParams(), tmCfg, false, genState, kr, tmrand.Str(6))
require.NoError(t, err)

cctx, stopNode, err := StartNode(tmNode, cctx)
Expand Down
2 changes: 1 addition & 1 deletion testutil/testnode/full_node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (s *IntegrationTestSuite) SetupSuite() {
genState, kr, err := DefaultGenesisState(s.accounts...)
require.NoError(err)

tmNode, app, cctx, err := New(s.T(), DefaultParams(), DefaultTendermintConfig(), false, genState, kr)
tmNode, app, cctx, err := New(s.T(), DefaultParams(), DefaultTendermintConfig(), false, genState, kr, tmrand.Str(6))
require.NoError(err)

cctx, stopNode, err := StartNode(tmNode, cctx)
Expand Down
6 changes: 5 additions & 1 deletion x/blob/types/payforblob.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,11 @@ func CreateCommitment(blob *Blob) ([]byte, error) {
}
}
// add the root
subTreeRoots[i] = tree.Root()
root, err := tree.Root()
if err != nil {
return nil, err
}
subTreeRoots[i] = root
}
return merkle.HashFromByteSlices(subTreeRoots), nil
}
Expand Down

0 comments on commit 9698a07

Please sign in to comment.