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

Add Blob.Index and fix Blob.Proof Serialization #108

Merged
merged 18 commits into from
Mar 18, 2024
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
16 changes: 8 additions & 8 deletions .github/auto_request_review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@
- code-owners
groups:
code-owners:
- Nashqueue
- tzdybal
- gupadhyaya
rollkit:
- Manav-Aggarwal
- Bidon15
- Ferret-san
- distractedm1nd
- YazzyYaz
celestia:
- Wondertan
- S1nus
- tuxcanfly
- vgonkivs
devops:
- smuu
- sysrex
- jrmanes
- Bidon15
celestia:

Check failure on line 18 in .github/auto_request_review.yml

View workflow job for this annotation

GitHub Actions / lint / yamllint

18:5 [key-duplicates] duplication of key "celestia" in mapping
- team:celestia
files:
'**':
- code-owners
- rollkit
- celestia
'**/*Dockerfile':
- devops
'.github/**':
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/housekeeping.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
# ignore dependabot PRs
if: ${{ github.actor != 'dependabot[bot]' }}
name: Add issues and PRs to project and add grooming label
uses: rollkit/.github/.github/workflows/[email protected]
uses: celestiaorg/.github/.github/workflows/[email protected]
secrets: inherit
permissions:
issues: write
Expand All @@ -20,12 +20,12 @@ jobs:
run-labels: true
labels-to-add: "needs-grooming"
run-projects: true
project-url: https://github.com/orgs/rollkit/projects/7
project-url: https://github.com/orgs/celestiaorg/projects/7

auto-add-reviewer:
name: Auto add reviewer to PR
if: github.event.pull_request
uses: rollkit/.github/.github/workflows/[email protected]
uses: celestiaorg/.github/.github/workflows/[email protected]
secrets: inherit
permissions:
issues: write
Expand Down
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ linters-settings:
- name: package-comments
disabled: true
goimports:
local-prefixes: github.com/rollkit
local-prefixes: github.com/celestia
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

OpenRPC is a client of [celestia-node RPC](https://docs.celestia.org/developers/node-api/), without depenencies on celestia-node/celestia-app/cosmos-sdk.

This is a temporary measure to resolve dependency issues when celestia-node is imported by rollkit.
This is a temporary measure to resolve dependency issues when celestia-node is imported by celestia.
32 changes: 14 additions & 18 deletions api.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import (
"context"

"github.com/celestiaorg/go-fraud"

Check failure on line 6 in api.go

View workflow job for this annotation

GitHub Actions / lint / golangci-lint

File is not `goimports`-ed with -local github.com/celestia (goimports)
libhead "github.com/celestiaorg/go-header"
"github.com/celestiaorg/go-header/sync"
"github.com/celestiaorg/rsmt2d"
Expand All @@ -14,12 +14,12 @@
"github.com/libp2p/go-libp2p/core/protocol"
rcmgr "github.com/libp2p/go-libp2p/p2p/host/resource-manager"

"github.com/rollkit/celestia-openrpc/types/blob"
"github.com/rollkit/celestia-openrpc/types/das"
"github.com/rollkit/celestia-openrpc/types/header"
"github.com/rollkit/celestia-openrpc/types/node"
"github.com/rollkit/celestia-openrpc/types/share"
"github.com/rollkit/celestia-openrpc/types/state"
"github.com/celestiaorg/celestia-openrpc/types/blob"
"github.com/celestiaorg/celestia-openrpc/types/das"
"github.com/celestiaorg/celestia-openrpc/types/header"
"github.com/celestiaorg/celestia-openrpc/types/node"
"github.com/celestiaorg/celestia-openrpc/types/share"
"github.com/celestiaorg/celestia-openrpc/types/state"
)

// Proof embeds the fraud.Proof interface type to provide a concrete type for JSON serialization.
Expand All @@ -38,7 +38,7 @@
}

type BlobAPI struct {
Submit func(context.Context, []*blob.Blob, *SubmitOptions) (uint64, error) `perm:"write"`
Submit func(context.Context, []*blob.Blob, GasPrice) (uint64, error) `perm:"write"`
Get func(context.Context, uint64, share.Namespace, blob.Commitment) (*blob.Blob, error) `perm:"read"`
GetAll func(context.Context, uint64, []share.Namespace) ([]*blob.Blob, error) `perm:"read"`
GetProof func(context.Context, uint64, share.Namespace, blob.Commitment) (*blob.Proof, error) `perm:"read"`
Expand Down Expand Up @@ -168,16 +168,12 @@
AuthNew func(ctx context.Context, perms []auth.Permission) ([]byte, error) `perm:"admin"`
}

// SubmitOptions contains the information about fee and gasLimit price in order to configure the Submit request.
type SubmitOptions struct {
Fee int64
GasLimit uint64
}
// GasPrice represents the amount to be paid per gas unit. Fee is set by
// multiplying GasPrice by GasLimit, which is determined by the blob sizes.
type GasPrice float64

// DefaultSubmitOptions creates a default fee and gas price values.
func DefaultSubmitOptions() *SubmitOptions {
return &SubmitOptions{
Fee: -1,
GasLimit: 0,
}
// DefaultGasPrice returns the default gas price, letting node automatically
// determine the Fee based on the passed blob sizes.
func DefaultGasPrice() GasPrice {
return -1.0
}
8 changes: 4 additions & 4 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import (
"github.com/ory/dockertest/v3"
"github.com/stretchr/testify/suite"

"github.com/rollkit/celestia-openrpc/types/blob"
"github.com/rollkit/celestia-openrpc/types/share"
"github.com/celestiaorg/celestia-openrpc/types/blob"
"github.com/celestiaorg/celestia-openrpc/types/share"
)

type TestSuite struct {
Expand Down Expand Up @@ -72,7 +72,7 @@ func (t *TestSuite) SetupSuite() {
buf := new(bytes.Buffer)
opts.StdOut = buf
opts.StdErr = buf
_, err = resource.Exec([]string{"/bin/celestia", "bridge", "auth", "admin", "--node.store", "/home/celestia/bridge"}, opts)
_, err = resource.Exec([]string{"/bin/celestia", "bridge", "auth", "admin", "--node.store", "/home/celestiaorg/bridge"}, opts)
if err != nil {
t.Failf("Could not execute command", "error: %v\n", err)
}
Expand Down Expand Up @@ -131,7 +131,7 @@ func (t *TestSuite) TestRoundTrip() {
t.Require().NoError(err)

// write blob to DA
height, err := client.Blob.Submit(ctx, []*blob.Blob{blobBlob}, nil)
height, err := client.Blob.Submit(ctx, []*blob.Blob{blobBlob}, DefaultGasPrice())
t.Require().NoError(err)
t.Require().NotZero(height)

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/rollkit/celestia-openrpc
module github.com/celestiaorg/celestia-openrpc

go 1.20

Expand Down
2 changes: 1 addition & 1 deletion types/appconsts/versioned_consts.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package appconsts

import v1 "github.com/rollkit/celestia-openrpc/types/appconsts/v1"
import v1 "github.com/celestiaorg/celestia-openrpc/types/appconsts/v1"

const (
LatestVersion = v1.Version
Expand Down
9 changes: 7 additions & 2 deletions types/blob/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (

"github.com/celestiaorg/nmt"

"github.com/rollkit/celestia-openrpc/types/appconsts"
"github.com/rollkit/celestia-openrpc/types/share"
"github.com/celestiaorg/celestia-openrpc/types/appconsts"
"github.com/celestiaorg/celestia-openrpc/types/share"
)

const (
Expand Down Expand Up @@ -48,6 +48,7 @@ type jsonBlob struct {
Data []byte `json:"data"`
ShareVersion uint32 `json:"share_version"`
Commitment Commitment `json:"commitment"`
Index int `json:"index"`
}

// Blob represents any application-specific binary data that anyone can submit to Celestia.
Expand All @@ -58,6 +59,7 @@ type Blob struct {
ShareVersion uint32 `protobuf:"varint,3,opt,name=share_version,json=shareVersion,proto3" json:"share_version,omitempty"`
NamespaceVersion uint32 `protobuf:"varint,4,opt,name=namespace_version,json=namespaceVersion,proto3" json:"namespace_version,omitempty"`
Commitment []byte `protobuf:"bytes,5,opt,name=commitment,proto3" json:"commitment,omitempty"`
Index int `protobuf:"varint,6,opt,name=index,proto3" json:"index,omitempty"`
}

func (b *Blob) MarshalJSON() ([]byte, error) {
Expand All @@ -66,6 +68,7 @@ func (b *Blob) MarshalJSON() ([]byte, error) {
Data: b.Data,
ShareVersion: b.ShareVersion,
Commitment: b.Commitment,
Index: b.Index,
}
return json.Marshal(blob)
}
Expand All @@ -81,6 +84,7 @@ func (b *Blob) UnmarshalJSON(data []byte) error {
b.ShareVersion = blob.ShareVersion
b.Commitment = blob.Commitment
b.Namespace = blob.Namespace
b.Index = blob.Index
return nil
}

Expand All @@ -105,5 +109,6 @@ func NewBlob(shareVersion uint8, namespace share.Namespace, data []byte) (*Blob,
ShareVersion: uint32(shareVersion),
NamespaceVersion: 0,
Commitment: []byte{},
Index: -1,
}, nil
}
4 changes: 2 additions & 2 deletions types/blob/blob_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (

"github.com/stretchr/testify/require"

"github.com/rollkit/celestia-openrpc/types/appconsts"
appns "github.com/rollkit/celestia-openrpc/types/namespace"
"github.com/celestiaorg/celestia-openrpc/types/appconsts"
appns "github.com/celestiaorg/celestia-openrpc/types/namespace"
)

func TestBlobMarshalUnmarshal(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions types/blob/commitment.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (

"github.com/celestiaorg/nmt"

"github.com/rollkit/celestia-openrpc/types/appconsts"
"github.com/rollkit/celestia-openrpc/types/share"
"github.com/celestiaorg/celestia-openrpc/types/appconsts"
"github.com/celestiaorg/celestia-openrpc/types/share"
)

// CreateCommitment generates the share commitment for a given blob.
Expand Down
2 changes: 1 addition & 1 deletion types/blob/share_splitting.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package blob

import "github.com/rollkit/celestia-openrpc/types/share"
import "github.com/celestiaorg/celestia-openrpc/types/share"

// SplitBlobs splits the provided blobs into shares.
func SplitBlobs(blobs ...Blob) ([]share.Share, error) {
Expand Down
2 changes: 1 addition & 1 deletion types/header/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
"encoding/json"
"time"

"github.com/celestiaorg/go-header"

Check failure on line 7 in types/header/header.go

View workflow job for this annotation

GitHub Actions / lint / golangci-lint

File is not `goimports`-ed with -local github.com/celestia (goimports)
cmjson "github.com/cometbft/cometbft/libs/json"

"github.com/rollkit/celestia-openrpc/types/core"
"github.com/celestiaorg/celestia-openrpc/types/core"
)

// RawHeader is an alias to core.Header. It is
Expand Down
2 changes: 1 addition & 1 deletion types/share/info_byte.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package share
import (
"fmt"

"github.com/rollkit/celestia-openrpc/types/appconsts"
"github.com/celestiaorg/celestia-openrpc/types/appconsts"
)

// InfoByte is a byte with the following structure: the first 7 bits are
Expand Down
4 changes: 2 additions & 2 deletions types/share/namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (

"github.com/celestiaorg/nmt/namespace"

"github.com/rollkit/celestia-openrpc/types/appconsts"
appns "github.com/rollkit/celestia-openrpc/types/namespace"
"github.com/celestiaorg/celestia-openrpc/types/appconsts"
appns "github.com/celestiaorg/celestia-openrpc/types/namespace"
)

// Various reserved namespaces.
Expand Down
4 changes: 2 additions & 2 deletions types/share/padding.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"bytes"
"errors"

"github.com/rollkit/celestia-openrpc/types/appconsts"
"github.com/rollkit/celestia-openrpc/types/namespace"
"github.com/celestiaorg/celestia-openrpc/types/appconsts"
"github.com/celestiaorg/celestia-openrpc/types/namespace"
)

// NamespacePaddingShare returns a share that acts as padding. Namespace padding
Expand Down
2 changes: 1 addition & 1 deletion types/share/reserved_bytes.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/binary"
"fmt"

"github.com/rollkit/celestia-openrpc/types/appconsts"
"github.com/celestiaorg/celestia-openrpc/types/appconsts"
)

// NewReservedBytes returns a byte slice of length
Expand Down
6 changes: 3 additions & 3 deletions types/share/share.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (

"github.com/celestiaorg/nmt"

"github.com/rollkit/celestia-openrpc/types/appconsts"
"github.com/rollkit/celestia-openrpc/types/core"
"github.com/rollkit/celestia-openrpc/types/namespace"
"github.com/celestiaorg/celestia-openrpc/types/appconsts"
"github.com/celestiaorg/celestia-openrpc/types/core"
"github.com/celestiaorg/celestia-openrpc/types/namespace"
)

// Root represents root commitment to multiple Shares.
Expand Down
4 changes: 2 additions & 2 deletions types/share/share_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"encoding/binary"
"errors"

"github.com/rollkit/celestia-openrpc/types/appconsts"
"github.com/rollkit/celestia-openrpc/types/namespace"
"github.com/celestiaorg/celestia-openrpc/types/appconsts"
"github.com/celestiaorg/celestia-openrpc/types/namespace"
)

type Builder struct {
Expand Down
4 changes: 2 additions & 2 deletions types/share/split_sparse_shares.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (

"golang.org/x/exp/slices"

"github.com/rollkit/celestia-openrpc/types/appconsts"
"github.com/rollkit/celestia-openrpc/types/namespace"
"github.com/celestiaorg/celestia-openrpc/types/appconsts"
"github.com/celestiaorg/celestia-openrpc/types/namespace"
)

// SparseShareSplitter lazily splits blobs into shares that will eventually be
Expand Down
2 changes: 1 addition & 1 deletion types/state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

coretypes "github.com/cometbft/cometbft/types"

"github.com/rollkit/celestia-openrpc/types/sdk"
"github.com/celestiaorg/celestia-openrpc/types/sdk"
)

// Balance is an alias to the Coin type from Cosmos-SDK.
Expand Down
Loading