Skip to content

Commit ec221ef

Browse files
authored
deps: fix dependency on celestia-app (#56)
1 parent e91b08a commit ec221ef

File tree

6 files changed

+295
-107
lines changed

6 files changed

+295
-107
lines changed

client.go

+5-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"errors"
77
"fmt"
88

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

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

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

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

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

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

122-
func namespacedPath(endpoint string, namespace appns.Namespace, height uint64) string {
121+
func namespacedPath(endpoint string, namespace Namespace, height uint64) string {
123122
return fmt.Sprintf("%s/%s/height/%d", endpoint, hex.EncodeToString(namespace.Bytes()), height)
124123
}

consts.go

+67
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
package cnc
22

3+
import (
4+
"bytes"
5+
"math"
6+
)
7+
38
const (
49
headerEndpoint = "/header"
510
balanceEndpoint = "/balance"
@@ -10,3 +15,65 @@ const (
1015

1116
heightKey = "height"
1217
)
18+
19+
const (
20+
// NamespaveVersionSize is the size of a namespace version in bytes.
21+
NamespaceVersionSize = 1
22+
23+
// NamespaceIDSize is the size of a namespace ID in bytes.
24+
NamespaceIDSize = 28
25+
26+
// NamespaceSize is the size of a namespace (version + ID) in bytes.
27+
NamespaceSize = NamespaceVersionSize + NamespaceIDSize
28+
29+
// NamespaceVersionZero is the first namespace version.
30+
NamespaceVersionZero = uint8(0)
31+
32+
// NamespaceVersionMax is the max namespace version.
33+
NamespaceVersionMax = math.MaxUint8
34+
35+
// NamespaceZeroPrefixSize is the number of `0` bytes that are prefixed to
36+
// namespace IDs for version 0.
37+
NamespaceVersionZeroPrefixSize = 18
38+
39+
// NamespaceVersionZeroIDSize is the number of bytes available for
40+
// user-specified namespace ID in a namespace ID for version 0.
41+
NamespaceVersionZeroIDSize = NamespaceIDSize - NamespaceVersionZeroPrefixSize
42+
)
43+
44+
var (
45+
// NamespaceVersionZeroPrefix is the prefix of a namespace ID for version 0.
46+
NamespaceVersionZeroPrefix = bytes.Repeat([]byte{0}, NamespaceVersionZeroPrefixSize)
47+
48+
// TxNamespace is the namespace reserved for transaction data.
49+
TxNamespace = MustNewV0([]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 1})
50+
51+
// IntermediateStateRootsNamespace is the namespace reserved for
52+
// intermediate state root data.
53+
IntermediateStateRootsNamespace = MustNewV0([]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 2})
54+
55+
// PayForBlobNamespace is the namespace reserved for PayForBlobs transactions.
56+
PayForBlobNamespace = MustNewV0([]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 4})
57+
58+
// ReservedPaddingNamespace is the namespace used for padding after all
59+
// reserved namespaces. In practice this padding is after transactions
60+
// (ordinary and PFBs) but before blobs.
61+
ReservedPaddingNamespace = MustNewV0([]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 255})
62+
63+
// MaxReservedNamespace is lexicographically the largest namespace that is
64+
// reserved for protocol use.
65+
MaxReservedNamespace = MustNewV0([]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 255})
66+
67+
// TailPaddingNamespace is the namespace reserved for tail padding. All data
68+
// with this namespace will be ignored.
69+
TailPaddingNamespace = Namespace{
70+
Version: math.MaxUint8,
71+
ID: append(bytes.Repeat([]byte{0xFF}, NamespaceIDSize-1), 0xFE),
72+
}
73+
74+
// ParitySharesNamespace is the namespace reserved for erasure coded data.
75+
ParitySharesNamespace = Namespace{
76+
Version: math.MaxUint8,
77+
ID: bytes.Repeat([]byte{0xFF}, NamespaceIDSize),
78+
}
79+
)

go.mod

+18-39
Original file line numberDiff line numberDiff line change
@@ -4,63 +4,42 @@ go 1.19
44

55
require (
66
github.com/go-resty/resty/v2 v2.7.0
7-
github.com/gogo/protobuf v1.3.3
7+
github.com/gogo/protobuf v1.3.2
88
github.com/google/uuid v1.3.0
9-
github.com/stretchr/testify v1.8.3
9+
github.com/stretchr/testify v1.8.2
1010
github.com/testcontainers/testcontainers-go v0.15.0
1111
)
1212

13-
require (
14-
github.com/Microsoft/hcsshim v0.9.4 // indirect
15-
github.com/celestiaorg/merkletree v0.0.0-20210714075610-a84dc3ddbbe4 // indirect
16-
github.com/celestiaorg/rsmt2d v0.9.0 // indirect
17-
github.com/containerd/cgroups v1.0.4 // indirect
18-
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
19-
github.com/klauspost/cpuid/v2 v2.1.1 // indirect
20-
github.com/klauspost/reedsolomon v1.11.1 // indirect
21-
github.com/minio/sha256-simd v1.0.0 // indirect
22-
github.com/moby/sys/mount v0.3.3 // indirect
23-
github.com/moby/sys/mountinfo v0.6.2 // indirect
24-
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect
25-
github.com/sasha-s/go-deadlock v0.3.1 // indirect
26-
github.com/tendermint/tendermint v0.34.24 // indirect
27-
go.opencensus.io v0.23.0 // indirect
28-
golang.org/x/mod v0.9.0 // indirect
29-
golang.org/x/sync v0.1.0 // indirect
30-
golang.org/x/tools v0.7.0 // indirect
31-
)
32-
3313
require (
3414
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
35-
github.com/Microsoft/go-winio v0.6.0 // indirect
36-
github.com/celestiaorg/celestia-app v1.0.0-rc0
15+
github.com/Microsoft/go-winio v0.5.2 // indirect
16+
github.com/Microsoft/hcsshim v0.9.4 // indirect
3717
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
18+
github.com/containerd/cgroups v1.0.4 // indirect
3819
github.com/containerd/containerd v1.6.8 // indirect
3920
github.com/davecgh/go-spew v1.1.1 // indirect
4021
github.com/docker/distribution v2.8.1+incompatible // indirect
41-
github.com/docker/docker v23.0.6+incompatible // indirect
22+
github.com/docker/docker v20.10.17+incompatible // indirect
4223
github.com/docker/go-connections v0.4.0 // indirect
4324
github.com/docker/go-units v0.5.0 // indirect
25+
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
4426
github.com/golang/protobuf v1.5.2 // indirect
4527
github.com/magiconair/properties v1.8.6 // indirect
46-
github.com/moby/term v0.0.0-20220808134915-39b0c02b01ae // indirect
28+
github.com/moby/sys/mount v0.3.3 // indirect
29+
github.com/moby/sys/mountinfo v0.6.2 // indirect
30+
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect
4731
github.com/morikuni/aec v1.0.0 // indirect
4832
github.com/opencontainers/go-digest v1.0.0 // indirect
49-
github.com/opencontainers/image-spec v1.1.0-rc2 // indirect
33+
github.com/opencontainers/image-spec v1.0.3-0.20211202183452-c5a74bcca799 // indirect
5034
github.com/opencontainers/runc v1.1.3 // indirect
5135
github.com/pkg/errors v0.9.1 // indirect
5236
github.com/pmezard/go-difflib v1.0.0 // indirect
53-
github.com/sirupsen/logrus v1.9.0 // indirect
54-
golang.org/x/net v0.8.0 // indirect
55-
golang.org/x/sys v0.6.0 // indirect
56-
google.golang.org/genproto v0.0.0-20221118155620-16455021b5e6 // indirect
57-
google.golang.org/grpc v1.52.0 // indirect
58-
google.golang.org/protobuf v1.28.2-0.20220831092852-f930b1dc76e8 // indirect
37+
github.com/sirupsen/logrus v1.8.1 // indirect
38+
go.opencensus.io v0.23.0 // indirect
39+
golang.org/x/net v0.0.0-20220617184016-355a448f1bc9 // indirect
40+
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect
41+
google.golang.org/genproto v0.0.0-20220617124728-180714bec0ad // indirect
42+
google.golang.org/grpc v1.47.0 // indirect
43+
google.golang.org/protobuf v1.28.0 // indirect
5944
gopkg.in/yaml.v3 v3.0.1 // indirect
6045
)
61-
62-
replace (
63-
github.com/docker/docker => github.com/docker/docker v20.10.17+incompatible
64-
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
65-
github.com/tendermint/tendermint => github.com/celestiaorg/celestia-core v1.21.1-tm-v0.34.27
66-
)

0 commit comments

Comments
 (0)