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

Update to the latest version of celestia-core #175

Merged
merged 10 commits into from
Nov 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ test:
.PHONY: test

PB_PKGS=$(shell find . -name 'pb' -type d)
PB_CORE=$(shell go list -f {{.Dir}} -m github.com/celestiaorg/celestia-core)
PB_CORE=$(shell go list -f {{.Dir}} -m github.com/tendermint/tendermint)
PB_GOGO=$(shell go list -f {{.Dir}} -m github.com/gogo/protobuf)

## pb-gen: Generate protobuf code for all /pb/*.proto files in the project.
Expand Down
8 changes: 4 additions & 4 deletions core/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package core
import (
"fmt"

corenode "github.com/celestiaorg/celestia-core/node"
"github.com/celestiaorg/celestia-core/rpc/client"
"github.com/celestiaorg/celestia-core/rpc/client/http"
"github.com/celestiaorg/celestia-core/rpc/client/local"
corenode "github.com/tendermint/tendermint/node"
"github.com/tendermint/tendermint/rpc/client"
"github.com/tendermint/tendermint/rpc/client/http"
"github.com/tendermint/tendermint/rpc/client/local"
)

// Client is an alias to Core Client.
Expand Down
2 changes: 1 addition & 1 deletion core/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"github.com/BurntSushi/toml"

"github.com/celestiaorg/celestia-core/config"
"github.com/tendermint/tendermint/config"
)

// Config is an alias for Core config.
Expand Down
3 changes: 2 additions & 1 deletion core/fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import (
"context"
"fmt"

"github.com/celestiaorg/celestia-core/types"
"github.com/tendermint/tendermint/types"

"github.com/celestiaorg/celestia-node/service/block"
)

Expand Down
2 changes: 1 addition & 1 deletion core/fetcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/celestiaorg/celestia-core/libs/bytes"
"github.com/tendermint/tendermint/libs/bytes"
)

func TestBlockFetcher_GetBlock_and_SubscribeNewBlockEvent(t *testing.T) {
Expand Down
15 changes: 6 additions & 9 deletions core/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import (
"fmt"
"path/filepath"

tmrand "github.com/celestiaorg/celestia-core/libs/rand"
"github.com/celestiaorg/celestia-core/p2p"
"github.com/celestiaorg/celestia-core/privval"
"github.com/celestiaorg/celestia-core/types"
tmtime "github.com/celestiaorg/celestia-core/types/time"
tmrand "github.com/tendermint/tendermint/libs/rand"
"github.com/tendermint/tendermint/p2p"
"github.com/tendermint/tendermint/privval"
"github.com/tendermint/tendermint/types"
tmtime "github.com/tendermint/tendermint/types/time"

"github.com/celestiaorg/celestia-node/libs/utils"
)
Expand Down Expand Up @@ -44,10 +44,7 @@ func Init(path string) (err error) {
var pv *privval.FilePV
keyPath := cfg.PrivValidatorKeyFile()
if !utils.Exists(keyPath) {
pv, err = privval.GenFilePV(keyPath, cfg.PrivValidatorStateFile(), defaultValKeyType)
if err != nil {
return
}
pv = privval.GenFilePV(keyPath, cfg.PrivValidatorStateFile())
pv.Save()
log.Info("New consensus private key is generated")
} else {
Expand Down
2 changes: 1 addition & 1 deletion core/log_adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

logging "github.com/ipfs/go-log/v2"

tmlog "github.com/celestiaorg/celestia-core/libs/log"
tmlog "github.com/tendermint/tendermint/libs/log"
)

var log = logging.Logger("core")
Expand Down
2 changes: 1 addition & 1 deletion core/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package core
import (
"errors"

"github.com/celestiaorg/celestia-core/config"
"github.com/tendermint/tendermint/config"
)

// ErrNotInited is used to signal when core is intended to be started without being initialized.
Expand Down
8 changes: 4 additions & 4 deletions core/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"os"
"testing"

"github.com/celestiaorg/celestia-core/abci/example/kvstore"
"github.com/celestiaorg/celestia-core/config"
"github.com/celestiaorg/celestia-core/node"
rpctest "github.com/celestiaorg/celestia-core/rpc/test"
"github.com/tendermint/tendermint/abci/example/kvstore"
"github.com/tendermint/tendermint/config"
"github.com/tendermint/tendermint/node"
rpctest "github.com/tendermint/tendermint/rpc/test"
)

// MockConfig provides a testing configuration for embedded Core Client.
Expand Down
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ replace github.com/ipfs/go-verifcid => github.com/celestiaorg/go-verifcid v0.0.1

require (
github.com/BurntSushi/toml v0.4.1
github.com/celestiaorg/celestia-core v0.0.2-0.20210924001615-488ac31b4b3c
github.com/celestiaorg/nmt v0.8.0
github.com/celestiaorg/rsmt2d v0.3.0
github.com/gogo/protobuf v1.3.2
Expand Down Expand Up @@ -37,6 +36,9 @@ require (
github.com/multiformats/go-multihash v0.0.15
github.com/spf13/cobra v1.2.1
github.com/stretchr/testify v1.7.1-0.20210427113832-6241f9ab9942
github.com/tendermint/tendermint v0.34.14
go.uber.org/fx v1.14.2
go.uber.org/zap v1.19.0
)

replace github.com/tendermint/tendermint v0.34.14 => github.com/celestiaorg/celestia-core v0.34.14-celestia
Wondertan marked this conversation as resolved.
Show resolved Hide resolved
272 changes: 117 additions & 155 deletions go.sum

Large diffs are not rendered by default.

41 changes: 34 additions & 7 deletions ipld/plugin/nmt_test.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
package plugin

import (
"bytes"
"math"
"math/rand"
"sort"
"strconv"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/celestiaorg/celestia-core/pkg/da"
"github.com/celestiaorg/celestia-core/testutils"
"github.com/tendermint/tendermint/pkg/da"
)

// TestNamespaceFromCID checks that deriving the Namespaced hash from
Expand All @@ -18,18 +20,19 @@ func TestNamespaceFromCID(t *testing.T) {
var tests = []struct {
randData [][]byte
}{
{randData: testutils.GenerateRandNamespacedRawData(4, namespaceSize, ShareSize)},
{randData: testutils.GenerateRandNamespacedRawData(16, 16, ShareSize)},
{randData: testutils.GenerateRandNamespacedRawData(4, 4, ShareSize)},
{randData: testutils.GenerateRandNamespacedRawData(4, namespaceSize, ShareSize/2)},
{randData: generateRandNamespacedRawData(4, namespaceSize, ShareSize)},
{randData: generateRandNamespacedRawData(16, 16, ShareSize)},
{randData: generateRandNamespacedRawData(4, 4, ShareSize)},
{randData: generateRandNamespacedRawData(4, namespaceSize, ShareSize/2)},
}

for i, tt := range tests {
t.Run(strconv.Itoa(i), func(t *testing.T) {
// create DAH from rand data
squareSize := uint64(math.Sqrt(float64(len(tt.randData))))
dah, err := da.NewDataAvailabilityHeader(squareSize, tt.randData)
eds, err := da.ExtendShares(squareSize, tt.randData)
require.NoError(t, err)
dah := da.NewDataAvailabilityHeader(eds)
// check to make sure NamespacedHash is correctly derived from CID
for _, row := range dah.RowsRoots {
c, err := CidFromNamespacedSha256(row)
Expand All @@ -41,3 +44,27 @@ func TestNamespaceFromCID(t *testing.T) {
})
}
}

// generateRandNamespacedRawData returns random namespaced raw data for testing purposes.
func generateRandNamespacedRawData(total, nidSize, leafSize uint32) [][]byte {
evan-forbes marked this conversation as resolved.
Show resolved Hide resolved
data := make([][]byte, total)
for i := uint32(0); i < total; i++ {
nid := make([]byte, nidSize)

rand.Read(nid)
data[i] = nid
}
sortByteArrays(data)
for i := uint32(0); i < total; i++ {
d := make([]byte, leafSize)

rand.Read(d)
data[i] = append(data[i], d...)
}

return data
}

func sortByteArrays(src [][]byte) {
sort.Slice(src, func(i, j int) bool { return bytes.Compare(src[i], src[j]) < 0 })
}
5 changes: 3 additions & 2 deletions ipld/read.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import (
"github.com/ipfs/go-cid"
ipld "github.com/ipfs/go-ipld-format"

"github.com/celestiaorg/celestia-core/pkg/da"
"github.com/celestiaorg/celestia-core/pkg/wrapper"
"github.com/tendermint/tendermint/pkg/da"
"github.com/tendermint/tendermint/pkg/wrapper"
Wondertan marked this conversation as resolved.
Show resolved Hide resolved

"github.com/celestiaorg/celestia-node/ipld/plugin"
"github.com/celestiaorg/nmt"
"github.com/celestiaorg/nmt/namespace"
Expand Down
36 changes: 28 additions & 8 deletions ipld/read_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ import (
mdutils "github.com/ipfs/go-merkledag/test"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/pkg/da"
"github.com/tendermint/tendermint/pkg/wrapper"

"github.com/celestiaorg/celestia-core/pkg/da"
"github.com/celestiaorg/celestia-core/pkg/wrapper"
"github.com/celestiaorg/celestia-core/testutils"
"github.com/celestiaorg/celestia-node/ipld/plugin"
"github.com/celestiaorg/celestia-node/service/header"
"github.com/celestiaorg/nmt"
Expand Down Expand Up @@ -239,10 +238,10 @@ func TestGetLeavesByNamespace(t *testing.T) {
var tests = []struct {
rawData [][]byte
}{
{rawData: testutils.GenerateRandNamespacedRawData(16, NamespaceSize, plugin.ShareSize)},
{rawData: testutils.GenerateRandNamespacedRawData(16, NamespaceSize, 8)},
{rawData: testutils.GenerateRandNamespacedRawData(4, NamespaceSize, plugin.ShareSize)},
{rawData: testutils.GenerateRandNamespacedRawData(16, NamespaceSize, 8)},
{rawData: generateRandNamespacedRawData(16, NamespaceSize, plugin.ShareSize)},
{rawData: generateRandNamespacedRawData(16, NamespaceSize, 8)},
{rawData: generateRandNamespacedRawData(4, NamespaceSize, plugin.ShareSize)},
{rawData: generateRandNamespacedRawData(16, NamespaceSize, 8)},
}

for i, tt := range tests {
Expand All @@ -257,8 +256,9 @@ func TestGetLeavesByNamespace(t *testing.T) {
tt.rawData[(len(tt.rawData)/2)+1] = expected

// generate DAH
dah, err := da.NewDataAvailabilityHeader(squareSize, tt.rawData)
eds, err := da.ExtendShares(squareSize, tt.rawData)
require.NoError(t, err)
dah := da.NewDataAvailabilityHeader(eds)

// put raw data in DAG
dag := mdutils.Mock()
Expand Down Expand Up @@ -297,3 +297,23 @@ func rowRootsByNamespaceID(nID namespace.ID, dah *da.DataAvailabilityHeader) ([]
}
return roots, nil
}

// generateRandNamespacedRawData returns random namespaced raw data for testing purposes.
func generateRandNamespacedRawData(total, nidSize, leafSize uint32) [][]byte {
data := make([][]byte, total)
for i := uint32(0); i < total; i++ {
nid := make([]byte, nidSize)

rand.Read(nid)
data[i] = nid
}
sortByteArrays(data)
for i := uint32(0); i < total; i++ {
d := make([]byte, leafSize)

rand.Read(d)
data[i] = append(data[i], d...)
}

return data
}
3 changes: 2 additions & 1 deletion ipld/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import (

"github.com/celestiaorg/rsmt2d"

"github.com/celestiaorg/celestia-core/pkg/wrapper"
"github.com/tendermint/tendermint/pkg/wrapper"

"github.com/celestiaorg/celestia-node/ipld/plugin"
)

Expand Down
2 changes: 1 addition & 1 deletion ipld/write.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/celestiaorg/nmt"
"github.com/celestiaorg/rsmt2d"

"github.com/celestiaorg/celestia-core/pkg/wrapper"
"github.com/tendermint/tendermint/pkg/wrapper"
)

// PutData posts erasured block data to IPFS using the provided ipld.NodeAdder.
Expand Down
3 changes: 2 additions & 1 deletion service/block/erasure.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ package block
import (
"math"

"github.com/celestiaorg/celestia-core/pkg/wrapper"
"github.com/tendermint/tendermint/pkg/wrapper"

"github.com/celestiaorg/rsmt2d"
)

Expand Down
6 changes: 3 additions & 3 deletions service/block/event_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/celestiaorg/celestia-core/testutils"
core "github.com/celestiaorg/celestia-core/types"
core "github.com/tendermint/tendermint/types"

"github.com/celestiaorg/celestia-node/service/header"
)

Expand Down Expand Up @@ -92,7 +92,7 @@ func (m *mockFetcher) generateBlocks(t *testing.T, num int) []Block {
func generateRawAndExtendedBlock(t *testing.T) (*RawBlock, *Block) {
t.Helper()

data, err := testutils.GenerateRandomBlockData(1, 1, 1, 1, 40)
data, err := GenerateRandomBlockData(1, 1, 1, 1, 40)
if err != nil {
t.Fatal(err)
}
Expand Down
Loading