jsonrpc

package
v1.0.0-rc.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 5, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

README

blob package

This package is a trimmed copy of code from celestia-node to stay JSON-compatible with the blob RPC without importing the full Cosmos/Celestia dependency set.

Upstream source

  • blob.go comes from celestia-node/blob/blob.go @ tag v0.28.4 (release v0.28.4), with unused pieces removed (blob v1, proof helpers, share length calc, appconsts dependency, etc.).
  • submit_options.go mirrors the exported JSON fields of celestia-node/state/tx_config.go @ the same tag, leaving out functional options, defaults, and Cosmos keyring helpers.

Why copy instead of import

  • Avoids pulling Cosmos SDK / celestia-app dependencies into ev-node for the small surface we need (blob JSON and commitment for v0).
  • Keeps binary size and module graph smaller while remaining wire-compatible with celestia-node's blob service.

Keeping it in sync

  • When celestia-node changes blob JSON or tx config fields, update this package manually:
    1. diff -u pkg/da/jsonrpc/blob.go ../Celestia/celestia-node/blob/blob.go
    2. diff -u pkg/da/jsonrpc/submit_options.go ../Celestia/celestia-node/state/tx_config.go
    3. Port only the fields/logic required for our RPC surface.
  • Consider adding a CI check that diffs these files against upstream to detect drift.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeID

func MakeID(height uint64, commitment Commitment) []byte

MakeID constructs a blob ID by prefixing the commitment with the height (little endian).

Types

type Blob

type Blob struct {
	*libshare.Blob `json:"blob"`

	Commitment Commitment `json:"commitment"`
	// contains filtered or unexported fields
}

Blob represents application-specific binary data that can be submitted to Celestia. It is intentionally compatible with celestia-node's blob.Blob JSON shape.

func NewBlob

func NewBlob(shareVersion uint8, namespace libshare.Namespace, data, signer, commitment []byte) (*Blob, error)

NewBlob constructs a new blob from the provided namespace, data, signer, and share version. If commitment is provided, it is used directly; otherwise it is computed. This is a lightly adapted copy of celestia-node/blob.NewBlob.

func NewBlobV0

func NewBlobV0(namespace libshare.Namespace, data []byte) (*Blob, error)

NewBlobV0 builds a version 0 blob (the only version we currently need).

func (*Blob) EqualCommitment

func (b *Blob) EqualCommitment(com Commitment) bool

EqualCommitment compares the blob's commitment with the provided one.

func (*Blob) Index

func (b *Blob) Index() int

Index returns the blob's first share index in the EDS (or -1 if unknown).

func (*Blob) MarshalJSON

func (b *Blob) MarshalJSON() ([]byte, error)

MarshalJSON matches celestia-node's blob JSON encoding.

func (*Blob) Namespace

func (b *Blob) Namespace() libshare.Namespace

Namespace returns the blob namespace.

func (*Blob) UnmarshalJSON

func (b *Blob) UnmarshalJSON(data []byte) error

UnmarshalJSON matches celestia-node's blob JSON decoding.

type BlobAPI

type BlobAPI struct {
	Internal struct {
		Submit func(
			context.Context,
			[]*Blob,
			*SubmitOptions,
		) (uint64, error) `perm:"write"`
		Get func(
			context.Context,
			uint64,
			libshare.Namespace,
			Commitment,
		) (*Blob, error) `perm:"read"`
		GetAll func(
			context.Context,
			uint64,
			[]libshare.Namespace,
		) ([]*Blob, error) `perm:"read"`
		GetProof func(
			context.Context,
			uint64,
			libshare.Namespace,
			Commitment,
		) (*Proof, error) `perm:"read"`
		Included func(
			context.Context,
			uint64,
			libshare.Namespace,
			*Proof,
			Commitment,
		) (bool, error) `perm:"read"`
		GetCommitmentProof func(
			context.Context,
			uint64,
			libshare.Namespace,
			[]byte,
		) (*CommitmentProof, error) `perm:"read"`
		Subscribe func(
			context.Context,
			libshare.Namespace,
		) (<-chan *SubscriptionResponse, error) `perm:"read"`
	}
}

BlobAPI mirrors celestia-node's blob module (nodebuilder/blob/blob.go). jsonrpc.NewClient wires Internal.* to RPC stubs.

func (*BlobAPI) Get

func (api *BlobAPI) Get(ctx context.Context, height uint64, namespace libshare.Namespace, commitment Commitment) (*Blob, error)

Get retrieves a blob by commitment under the given namespace and height.

func (*BlobAPI) GetAll

func (api *BlobAPI) GetAll(ctx context.Context, height uint64, namespaces []libshare.Namespace) ([]*Blob, error)

GetAll returns all blobs for the given namespaces at the given height.

func (*BlobAPI) GetCommitmentProof

func (api *BlobAPI) GetCommitmentProof(ctx context.Context, height uint64, namespace libshare.Namespace, shareCommitment []byte) (*CommitmentProof, error)

GetCommitmentProof generates a commitment proof for a share commitment.

func (*BlobAPI) GetProof

func (api *BlobAPI) GetProof(ctx context.Context, height uint64, namespace libshare.Namespace, commitment Commitment) (*Proof, error)

GetProof retrieves proofs in the given namespace at the given height by commitment.

func (*BlobAPI) Included

func (api *BlobAPI) Included(ctx context.Context, height uint64, namespace libshare.Namespace, proof *Proof, commitment Commitment) (bool, error)

Included checks whether a blob commitment is included at the given height/namespace.

func (*BlobAPI) Submit

func (api *BlobAPI) Submit(ctx context.Context, blobs []*Blob, opts *SubmitOptions) (uint64, error)

Submit sends blobs and returns the height they were included at.

func (*BlobAPI) Subscribe

func (api *BlobAPI) Subscribe(ctx context.Context, namespace libshare.Namespace) (<-chan *SubscriptionResponse, error)

Subscribe streams blobs as they are included for the given namespace.

type BlobModule

BlobModule is the server-side "blob" JSON-RPC interface used by tests/mocks.

type Client

type Client struct {
	Blob   BlobAPI
	Header HeaderAPI
	// contains filtered or unexported fields
}

Client dials the celestia-node RPC "blob" and "header" namespaces.

func NewClient

func NewClient(ctx context.Context, addr, token string, authHeaderName string) (*Client, error)

NewClient connects to the celestia-node RPC endpoint

func (*Client) Close

func (c *Client) Close()

Close closes the underlying JSON-RPC connection.

type Commit

type Commit struct {
	Height string `json:"height"`
}

Commit contains commit information.

type Commitment

type Commitment []byte

Commitment is the Merkle subtree commitment for a blob.

func SplitID

func SplitID(id []byte) (uint64, Commitment)

SplitID splits a blob ID into height and commitment. If the ID is malformed, it returns height 0 and nil commitment.

type CommitmentProof

type CommitmentProof struct {
	SubtreeRoots [][]byte `json:"subtree_roots,omitempty"`
}

CommitmentProof matches celestia-node's blob.CommitmentProof JSON shape. We keep only the fields we need on the client side.

type DAHeader

type DAHeader struct {
	RowRoots    [][]byte `json:"row_roots"`
	ColumnRoots [][]byte `json:"column_roots"`
}

DAHeader contains the Data Availability header.

type Header struct {
	Header    RawHeader `json:"header"`
	Commit    Commit    `json:"commit"`
	DAH       DAHeader  `json:"dah"`
	Height    uint64    `json:"height,string,omitempty"`
	LastHash  []byte    `json:"last_header_hash,omitempty"`
	ChainID   string    `json:"chain_id,omitempty"`
	BlockTime time.Time `json:"time,omitempty"`
}

Header contains the fields from celestia-node's header.ExtendedHeader that we need. We only extract the Time field for timestamp determinism.

func (*Header) Time

func (h *Header) Time() time.Time

Time returns the block time from the header.

type HeaderAPI

type HeaderAPI struct {
	Internal struct {
		GetByHeight func(
			context.Context,
			uint64,
		) (*Header, error) `perm:"read"`
		LocalHead func(
			context.Context,
		) (*Header, error) `perm:"read"`
		NetworkHead func(
			context.Context,
		) (*Header, error) `perm:"read"`
	}
}

HeaderAPI mirrors celestia-node's header module. jsonrpc.NewClient wires Internal.* to RPC stubs.

func (*HeaderAPI) GetByHeight

func (api *HeaderAPI) GetByHeight(ctx context.Context, height uint64) (*Header, error)

GetByHeight retrieves a header at the specified height.

func (*HeaderAPI) LocalHead

func (api *HeaderAPI) LocalHead(ctx context.Context) (*Header, error)

LocalHead retrieves the locally synced head header.

func (*HeaderAPI) NetworkHead

func (api *HeaderAPI) NetworkHead(ctx context.Context) (*Header, error)

NetworkHead retrieves the network head header.

type HeaderModule

type HeaderModule interface {
	GetByHeight(context.Context, uint64) (*Header, error)
	LocalHead(context.Context) (*Header, error)
	NetworkHead(context.Context) (*Header, error)
}

HeaderModule is the server-side "header" JSON-RPC interface used by tests/mocks.

type Proof

type Proof []*nmt.Proof

Proof is a set of NMT proofs used to verify a blob inclusion. This mirrors celestia-node's blob.Proof shape.

type RawHeader

type RawHeader struct {
	ChainID string    `json:"chain_id"`
	Height  string    `json:"height"`
	Time    time.Time `json:"time"`
}

RawHeader contains the raw tendermint header fields.

type SubmitOptions

type SubmitOptions struct {
	GasPrice          float64    `json:"gas_price,omitempty"`
	IsGasPriceSet     bool       `json:"is_gas_price_set,omitempty"`
	MaxGasPrice       float64    `json:"max_gas_price,omitempty"`
	Gas               uint64     `json:"gas,omitempty"`
	TxPriority        TxPriority `json:"tx_priority,omitempty"`
	KeyName           string     `json:"key_name,omitempty"`
	SignerAddress     string     `json:"signer_address,omitempty"`
	FeeGranterAddress string     `json:"fee_granter_address,omitempty"`
}

SubmitOptions is a pared-down copy of celestia-node/state.TxConfig JSON shape. Only exported fields are marshalled to match the RPC expectation of the blob service.

type SubscriptionResponse

type SubscriptionResponse struct {
	Blobs  []*Blob `json:"blobs"`
	Height uint64  `json:"height"`
}

SubscriptionResponse mirrors celestia-node's blob.SubscriptionResponse.

type TxPriority

type TxPriority int

TxPriority mirrors celestia-node/state.TxPriority to preserve JSON compatibility.

const (
	TxPriorityLow TxPriority = iota + 1
	TxPriorityMedium
	TxPriorityHigh
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL