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

deps: fix dependency on celestia-app #56

Merged
merged 1 commit into from
May 31, 2023
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
11 changes: 5 additions & 6 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"errors"
"fmt"

appns "github.com/celestiaorg/celestia-app/pkg/namespace"
"github.com/go-resty/resty/v2"
)

Expand Down Expand Up @@ -45,7 +44,7 @@ func (c *Client) SubmitTx(ctx context.Context, tx []byte) /* TxResponse */ error
return errors.New("method SubmitTx not implemented")
}

func (c *Client) SubmitPFB(ctx context.Context, namespace appns.Namespace, data []byte, fee int64, gasLimit uint64) (*TxResponse, error) {
func (c *Client) SubmitPFB(ctx context.Context, namespace Namespace, data []byte, fee int64, gasLimit uint64) (*TxResponse, error) {
req := SubmitPFBRequest{
// FIXME: See https://github.com/celestiaorg/celestia-node/issues/2292
NamespaceID: hex.EncodeToString(namespace.Bytes()[1:]),
Expand All @@ -70,7 +69,7 @@ func (c *Client) SubmitPFB(ctx context.Context, namespace appns.Namespace, data
return &res, nil
}

func (c *Client) NamespacedShares(ctx context.Context, namespace appns.Namespace, height uint64) ([][]byte, error) {
func (c *Client) NamespacedShares(ctx context.Context, namespace Namespace, height uint64) ([][]byte, error) {
var res struct {
Shares [][]byte `json:"shares"`
Height uint64 `json:"height"`
Expand All @@ -84,7 +83,7 @@ func (c *Client) NamespacedShares(ctx context.Context, namespace appns.Namespace
return res.Shares, nil
}

func (c *Client) NamespacedData(ctx context.Context, namespace appns.Namespace, height uint64) ([][]byte, error) {
func (c *Client) NamespacedData(ctx context.Context, namespace Namespace, height uint64) ([][]byte, error) {
var res struct {
Data [][]byte `json:"data"`
Height uint64 `json:"height"`
Expand All @@ -99,7 +98,7 @@ func (c *Client) NamespacedData(ctx context.Context, namespace appns.Namespace,
}

// callNamespacedEndpoint fetches result of /namespaced_{type} family of endpoints into result (this should be pointer!)
func (c *Client) callNamespacedEndpoint(ctx context.Context, namespace appns.Namespace, height uint64, endpoint string, result interface{}) error {
func (c *Client) callNamespacedEndpoint(ctx context.Context, namespace Namespace, height uint64, endpoint string, result interface{}) error {
var rpcErr string
_, err := c.c.R().
SetContext(ctx).
Expand All @@ -119,6 +118,6 @@ func headerPath() string {
return fmt.Sprintf("%s/%s", headerEndpoint, heightKey)
}

func namespacedPath(endpoint string, namespace appns.Namespace, height uint64) string {
func namespacedPath(endpoint string, namespace Namespace, height uint64) string {
return fmt.Sprintf("%s/%s/height/%d", endpoint, hex.EncodeToString(namespace.Bytes()), height)
}
67 changes: 67 additions & 0 deletions consts.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package cnc

import (
"bytes"
"math"
)

const (
headerEndpoint = "/header"
balanceEndpoint = "/balance"
Expand All @@ -10,3 +15,65 @@ const (

heightKey = "height"
)

const (
// NamespaveVersionSize is the size of a namespace version in bytes.
NamespaceVersionSize = 1

// NamespaceIDSize is the size of a namespace ID in bytes.
NamespaceIDSize = 28

// NamespaceSize is the size of a namespace (version + ID) in bytes.
NamespaceSize = NamespaceVersionSize + NamespaceIDSize

// NamespaceVersionZero is the first namespace version.
NamespaceVersionZero = uint8(0)

// NamespaceVersionMax is the max namespace version.
NamespaceVersionMax = math.MaxUint8

// NamespaceZeroPrefixSize is the number of `0` bytes that are prefixed to
// namespace IDs for version 0.
NamespaceVersionZeroPrefixSize = 18

// NamespaceVersionZeroIDSize is the number of bytes available for
// user-specified namespace ID in a namespace ID for version 0.
NamespaceVersionZeroIDSize = NamespaceIDSize - NamespaceVersionZeroPrefixSize
)

var (
// NamespaceVersionZeroPrefix is the prefix of a namespace ID for version 0.
NamespaceVersionZeroPrefix = bytes.Repeat([]byte{0}, NamespaceVersionZeroPrefixSize)

// TxNamespace is the namespace reserved for transaction data.
TxNamespace = MustNewV0([]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 1})

// IntermediateStateRootsNamespace is the namespace reserved for
// intermediate state root data.
IntermediateStateRootsNamespace = MustNewV0([]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 2})

// PayForBlobNamespace is the namespace reserved for PayForBlobs transactions.
PayForBlobNamespace = MustNewV0([]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 4})

// ReservedPaddingNamespace is the namespace used for padding after all
// reserved namespaces. In practice this padding is after transactions
// (ordinary and PFBs) but before blobs.
ReservedPaddingNamespace = MustNewV0([]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 255})

// MaxReservedNamespace is lexicographically the largest namespace that is
// reserved for protocol use.
MaxReservedNamespace = MustNewV0([]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 255})

// TailPaddingNamespace is the namespace reserved for tail padding. All data
// with this namespace will be ignored.
TailPaddingNamespace = Namespace{
Version: math.MaxUint8,
ID: append(bytes.Repeat([]byte{0xFF}, NamespaceIDSize-1), 0xFE),
}

// ParitySharesNamespace is the namespace reserved for erasure coded data.
ParitySharesNamespace = Namespace{
Version: math.MaxUint8,
ID: bytes.Repeat([]byte{0xFF}, NamespaceIDSize),
}
)
57 changes: 18 additions & 39 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,63 +4,42 @@ go 1.19

require (
github.com/go-resty/resty/v2 v2.7.0
github.com/gogo/protobuf v1.3.3
github.com/gogo/protobuf v1.3.2
github.com/google/uuid v1.3.0
github.com/stretchr/testify v1.8.3
github.com/stretchr/testify v1.8.2
github.com/testcontainers/testcontainers-go v0.15.0
)

require (
github.com/Microsoft/hcsshim v0.9.4 // indirect
github.com/celestiaorg/merkletree v0.0.0-20210714075610-a84dc3ddbbe4 // indirect
github.com/celestiaorg/rsmt2d v0.9.0 // indirect
github.com/containerd/cgroups v1.0.4 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/klauspost/cpuid/v2 v2.1.1 // indirect
github.com/klauspost/reedsolomon v1.11.1 // indirect
github.com/minio/sha256-simd v1.0.0 // indirect
github.com/moby/sys/mount v0.3.3 // indirect
github.com/moby/sys/mountinfo v0.6.2 // indirect
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect
github.com/sasha-s/go-deadlock v0.3.1 // indirect
github.com/tendermint/tendermint v0.34.24 // indirect
go.opencensus.io v0.23.0 // indirect
golang.org/x/mod v0.9.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/tools v0.7.0 // indirect
)

require (
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
github.com/Microsoft/go-winio v0.6.0 // indirect
github.com/celestiaorg/celestia-app v1.0.0-rc0
github.com/Microsoft/go-winio v0.5.2 // indirect
github.com/Microsoft/hcsshim v0.9.4 // indirect
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
github.com/containerd/cgroups v1.0.4 // indirect
github.com/containerd/containerd v1.6.8 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/docker/distribution v2.8.1+incompatible // indirect
github.com/docker/docker v23.0.6+incompatible // indirect
github.com/docker/docker v20.10.17+incompatible // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/moby/term v0.0.0-20220808134915-39b0c02b01ae // indirect
github.com/moby/sys/mount v0.3.3 // indirect
github.com/moby/sys/mountinfo v0.6.2 // indirect
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0-rc2 // indirect
github.com/opencontainers/image-spec v1.0.3-0.20211202183452-c5a74bcca799 // indirect
github.com/opencontainers/runc v1.1.3 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
golang.org/x/net v0.8.0 // indirect
golang.org/x/sys v0.6.0 // indirect
google.golang.org/genproto v0.0.0-20221118155620-16455021b5e6 // indirect
google.golang.org/grpc v1.52.0 // indirect
google.golang.org/protobuf v1.28.2-0.20220831092852-f930b1dc76e8 // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
go.opencensus.io v0.23.0 // indirect
golang.org/x/net v0.0.0-20220617184016-355a448f1bc9 // indirect
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect
google.golang.org/genproto v0.0.0-20220617124728-180714bec0ad // indirect
google.golang.org/grpc v1.47.0 // indirect
google.golang.org/protobuf v1.28.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace (
github.com/docker/docker => github.com/docker/docker v20.10.17+incompatible
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
github.com/tendermint/tendermint => github.com/celestiaorg/celestia-core v1.21.1-tm-v0.34.27
)
Loading