bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 20쪽 중 2쪽
te("First blob"), nil)
if err != nil {
return err
}
blob2, err := blob.NewBlob(share.ShareVersionZero, ns, []byte("Second blob"), nil)
if err != nil {
return err
}
blob3, err := blob.NewBlob(share.ShareVersionZero, ns, []byte("Third blob"), nil)
if err != nil {
return err
}
// Submit all blobs in a single transaction
height, err := c.Blob.Submit(ctx, []*blob.Blob{blob1, blob2, blob3}, nil)
if err != nil {
return err
}
fmt.Printf("✓ All 3 blobs submitted at block %d\n", height)
// Retrieve each blob using its unique commitment
retrieved1, _ := c.Blob.Get(ctx, height, ns, blob1.Commitment)
retrieved2, _ := c.Blob.Get(ctx, height, ns, blob2.Commitment)
retrieved3, _ := c.Blob.Get(ctx, height, ns, blob3.Commitment)
fmt.Printf("✓ Retrieved: %s, %s, %s\n",
string(retrieved1.Data()),
string(retrieved2.Data()),
string(retrieved3.Data()))
return nil
}
```
**Key points:**
- All blobs in the array are included in a single `PayForBlobs` transaction
- They all appear at the same block height
- Each blob can have a different namespace
- Retrieve blobs individually using their namespace and commitment
### Transaction submission modes
Celestia supports three transaction submission modes controlled by `TxWorkerAccounts` in your client configuration. This setting affects how transactions are queued and submitted, impacting throughput and ordering guarantees.
#### Default mode (TxWorkerAccounts = 0)
This is the default behavior (same as the basic tutorial). Transactions are submitted immediately without a queue:
```go
cfg := client.Config{
ReadConfig: client.ReadConfig{
BridgeDAAddr: daURL,
EnableDATLS: daTLS,
},
SubmitConfig: client.SubmitConfig{
DefaultKeyName: "my_key",
Network: p2p.Network("mocha-5"),
CoreGRPCConfig: client.CoreGRPCConfig{
Addr: coreGRPC,
TLSEnabled: coreTLS,
},
// TxWorkerAccounts defaults to 0 (immediate submission)
},
}
```
**Characteristics:**
- Transactions enter the mempool immediately
- No queuing or waiting for confirmations
- Potential sequence number conflicts if submitting multiple transactions quickly
- Same behavior as versions prior to v0.28.2
#### Queued mode (TxWorkerAccounts = 1)
Enable synchronous, ordered submission by setting `TxWorkerAccounts` to `1`:
```go
cfg.SubmitConfig.TxWorkerAccounts = 1
```
**Characteristics:**
- Each transaction queues until the previous one is confirmed
- Preserves strict ordering of transactions based on submission time
- Works with both sequential and concurrent submission patterns
- Avoids sequence mismatch errors
- Throughput: approximately 1 PayForBlobs transaction every other block
**Example:** Submitting 5 blobs in queued mode:
```go
import (
"golang.org/x/sync/errgroup"
)
func submitBlobsQueued(ctx context.Context, c *client.Client) error {
// Create 5 blobs
blobs := make([]*blob.Blob, 5)
namespaces := make([]share.Namespace, 5)
commitments := make([][]byte, 5)
for i := 0; i < 5; i++ {
nsBytes := make([]byte, 10)
copy(nsBytes, fmt.Sprintf("blob-%d", i))
ns, _ := share.NewV0Namespace(nsBytes)
namespaces[i] = ns
blobs[i], _ = blob.NewBlob(share.ShareVersionZero, ns,
[]byte(fmt.Sprintf("Data %d", i)), nil)
commitments[i] = blobs[i].Commitment
}
heights := make([]uint64, 5)
var g errgroup.Group
for i := 0; i < 5; i++ {
idx := i
g.Go(func() error {
height, err := c.Blob.Submit(ctx, []*blob.Blob{blobs[idx]}, nil)
if err != nil {
return err
}
heights[idx] = height
fmt.Printf("Blob %d submitted at height %d\n", idx+1, height)
return nil
})
}
if err := g.Wait(); err != nil {
return err
}
// Retrieve and verify all blobs
for i := 0; i < 5; i++ {
retrieved, err := c.Blob.Get(ctx, heights[i], namespaces[i], commitments[i])
if err != nil {
return err
}
fmt.Printf("✓ Blob %d retrieved: %s\n", i+1, string(retrieved.Data()))
}
return nil
}
```
**Expected output:**
```
Blob 3 submitted at height 1234567 // First to call Submit()
Blob 1 submitted at height 1234568 // Second to call Submit()
Blob 5 submitted at height 1234569 // Third to call Submit()
Blob 2 submitted at height 1234570 // Fourth to call Submit()
Blob 4 submitted at height 1234571 // Fifth to call Submit()
✓ Blob 1 retrieved: Data 0
✓ Blob 2 retrieved: Data 1
✓ Blob 3 retrieved: Data 2
✓ Blob 4 retrieved: Data 3
✓ Blob 5 retrieved: Data 4
```
Note: With concurrent submission, blobs may print in any order, but their heights will always reflect their submission order (first submitted = lowest height).
#### Parallel mode (TxWorkerAccounts > 1)
For high-throughput applications that don't require sequential ordering, enable parallel submission:
```go
cfg.SubmitConfig.TxWorkerAccounts = 8 // Creates 8 parallel lanes
```
**How it works:**
- Creates `TxWorkerAccounts` parallel submission lanes
- Each lane is a subaccount automatically created and funded from your default account
- Example: `TxWorkerAccounts = 8` creates 7 subaccounts + 1 default account = 8 parallel lanes
- Enables at least 8 PayForBlobs transactions per block
**Important:** To actually utilize parallel lanes, you must submit blobs concurrently (using goroutines). Each `Blob.Submit()` call blocks until the transaction is confirmed, so sequential calls will still be processed sequentially even with `TxWorkerAccounts > 1`. Concurrent submission allows multiple transactions to be processed simultaneously across different parallel lanes.
**Example:** Submitting 8 blobs concurrently in parallel mode:
```go
import (
"golang.org/x/sync/errgroup"
)
func submitBlobsParallel(ctx context.Context, c *client.Client) error {
// Create 8 blobs
blobs := make([]*blob.Blob, 8)
namespaces := make([]share.Namespace, 8)
commitments := make([][]byte, 8)
for i := 0; i < 8; i++ {
nsBytes := make([]byte, 10)
copy(nsBytes, fmt.Sprintf("parallel-%d", i))
ns, _ := share.NewV0Namespace(nsBytes)
namespaces[i] = ns
blobs[i], _ = blob.NewBlob(share.ShareVersionZero, ns,
[]byte(fmt.Sprintf("Parallel data %d", i)), nil)
commitments[i] = blobs[i].Commitment
}
heights := make([]uint64, 8)
var g errgroup.Group
for i := 0; i < 8; i++ {
idx := i
g.Go(func() error {
height, err := c.Blob.Submit(ctx, []*blob.Blob{blobs[idx]}, nil)
if err != nil {
return err
}
heights[idx] = height
fmt.Printf("Blob %d submitted at height %d\n", idx+1, height)
return nil
})
}
if err := g.Wait(); err != nil {
return err
}
// Retrieve and verify all blobs
for i := 0; i < 8; i++ {
retrieved, err := c.Blob.Get(ctx, heights[i], namespaces[i], commitments[i])
if err != nil {
return err
}
fmt.Printf("✓ Blob %d retrieved: %s\n", i+1, string(retrieved.Data()))
}
return nil
}
```
**Expected output (unordered):**
```
Blob 1 submitted at height 1234567
Blob 2 submitted at height 1234567 // Same block!
Blob 3 submitted at height 1234568
Blob 4 submitted at height 1234567 // Same block as 1 and 2!
Blob 5 submitted at height 1234568
Blob 6 submitted at height 1234568
Blob 7 submitted at height 1234569
Blob 8 submitted at height 1234568
✓ Blob 1 retrieved: Parallel data 0
✓ Blob 2 retrieved: Parallel data 1
✓ Blob 3 retrieved: Parallel data 2
✓ Blob 4 retrieved: Parallel data 3
✓ Blob 5 retrieved: Parallel data 4
✓ Blob 6 retrieved: Parallel data 5
✓ Blob 7 retrieved: Parallel data 6
✓ Blob 8 retrieved: Parallel data 7
```
**Important considerations:**
**Ordering**: Parallel submission does NOT guarantee transaction ordering. Blobs may be included in blocks in a different order than submitted.
**Default account only**: Queued and parallel submission modes always use your default account (`DefaultKeyName`). If you specify a different account in `TxConfig` (via `WithKeyName` or `WithSignerAddress`), it will be ignored and the default account will be used instead.
**Retrieving blobs from parallel submission:**
Since you don't know which subaccount submitted each blob, retrieve them using namespace, height, and commitment:
```go
// Store these when submitting
height, err := c.Blob.Submit(ctx, []*blob.Blob{myBlob}, nil)
commitment := myBlob.Commitment
namespace := myBlob.Namespace()
// Later, retrieve using stored values
retrieved, err := c.Blob.Get(ctx, height, namespace, commitment)
```
**Subaccount management:**
- Subaccounts are automatically created and funded from your default account
- They are named `parallel-worker-1`, `parallel-worker-2`, etc. in your keyring
- Subaccounts are reused across node restarts if `TxWorkerAccounts` value remains the same
- If you decrease `TxWorkerAccounts`, only the first N workers are used
- If you increase `TxWorkerAccounts`, additional workers are created
#### Comparison table
| Mode | TxWorkerAccounts | Ordering | Throughput | Use case |
| -------- | ---------------- | -------------- | ---------------- | ---------------------------------------- |
| Default | 0 | Not guaranteed | Immediate | Simple applications, single transactions |
| Queued | 1 | Guaranteed | ~1 tx per block | Applications requiring strict ordering |
| Parallel | >1 | Not guaranteed | ≥N txs per block | High-throughput, unordered workflows |
## Next steps
- **Production**: Use `keyring.BackendFile` instead of `keyring.BackendTest`
- **Security**: Enable TLS with authentication tokens for production
- **Advanced**: Read the [full client documentation](https://github.com/celestiaorg/celestia-node/blob/main/api/client#readme)
## Troubleshooting
Common errors and solutions:
### Connection errors
**`failed to initialize [share|header|blob] client`**
- Check that your `CELE_DA_URL` is correct and accessible
- Verify the bridge node is running and reachable
- Ensure TLS settings match your node configuration
**`couldn't connect to core endpoint`**
- Verify your `CELE_CORE_GRPC` address is correct
- Check that the consensus node is running
- Ensure firewall rules allow the connection
### Configuration errors
**`default key name should not be empty`**
- Ensure `DefaultKeyName` is set in your `SubmitConfig`
**`keyring is nil`**
- Pass a valid keyring to `client.New()` (cannot be `nil`)
### Blob submission errors
**`blob: not found`**
- The blob doesn't exist at the specified height/namespace/commitment
- Verify the height, namespace, and commitment are correct
**`not allowed namespace ... were used to build the blob`**
- The namespace is reserved or invalid
- Use `share.NewV0Namespace()` with valid user namespaces
**`account for signer ... not found`**
- The account has not been funded yet
- Fund your account at the [Mocha faucet](/operate/networks/mocha-testnet#mocha-testnet-faucet)
**`failed to submit blobs due to insufficient gas price`**
- The estimated or configured gas price is too low
- Either increase `MaxGasPrice` in `TxConfig` or let the client estimate
- Check network congestion (gas prices may be elevated)
**`context deadline exceeded`**
- Network timeout occurred
- Increase the context timeout: `context.WithTimeout(ctx, 5*time.Minute)`
- Check network connectivity to the node
---
Title: Rust client
URL: https://docs.celestia.org/build/post-retrieve-blob/client/rust.md
Source: app/build/post-retrieve-blob/client/rust/page.mdx
---
# Rust client
The [Lumina Rust client](https://github.com/celestiaorg/lumina/tree/main/client) provides a high-level API for interacting with a Celestia node over RPC and gRPC. It builds on top of the lower-level `celestia-rpc` and `celestia-grpc` crates and exposes a unified `Client` that supports both **read-only** and **submit** modes.
In read-only mode, the client connects to a node via RPC (and optionally gRPC) to query headers, blobs, and state.
In submit mode, it additionally uses gRPC and a local signer to build, sign, and broadcast transactions such as transfers and PayForBlobs.
The crate re-exports common Celestia types (namespaces, blobs, app versions, etc.) and is designed to be the easiest way for Rust applications to integrate with Celestia nodes for data retrieval, blob submission, and general chain interaction. ([lib.rs][1], [docs.rs][2])
[1]: https://lib.rs/crates/celestia-client "celestia-client, in Rust // Lib.rs"
[2]: https://docs.rs/celestia-client/latest/celestia_client/ "celestia-client, in Rust // Docs.rs"
---
Title: Submit and retrieve a Fibre blob on Mocha
URL: https://docs.celestia.org/build/post-retrieve-blob/fibre.md
Source: app/build/post-retrieve-blob/fibre/page.mdx
---
# Submit and retrieve a Fibre blob on Mocha
Fibre stores blob shards on validator-operated servers and settles payment
on-chain with `MsgPayForFibre`. This walkthrough deposits testnet TIA into
escrow, submits a namespaced payload, waits for settlement, and downloads the
original bytes.
Use `fibre.Submit` for this first test: it waits for transaction confirmation.
Fibre is separate from the [blob/transaction client flow](/build/post-retrieve-blob/overview)
that uses `blob.Submit` and PayForBlob. Fibre retrieval uses a `blob_id`, rather
than the height, namespace and commitment tuple used by `blob.Get`.
## Prepare a Mocha node
You need:
- A Mocha light or bridge node with Fibre support. The examples use
celestia-node `v0.34.3-mocha` and a core endpoint running
celestia-app `v10.4.0-mocha` on `mocha-5`.
Follow [Install celestia-node](/operate/data-availability/install-celestia-node).
- Bash, `curl`, `jq` and Python 3 for the commands below.
- A local signer funded with Mocha testnet TIA.
- Enough reachable Fibre providers to collect signatures representing the
required two-thirds of voting power. Check the
[Mocha Fibre dashboard](https://testnet.celestia.valopers.com/fibre).
App v10 activation alone does not establish provider readiness.
Check `celestia version` before starting. Older node releases without the
`fibre` API cannot run these requests. The
[released Node API reference](/build/rpc/node-api)
covers these methods when you select `v0.34.2-mocha`.
Select the specification that matches your node version.
If you already have a synced Mocha light or bridge node with a Fibre-capable
core endpoint, use its store, key and RPC address. Otherwise, initialise a
separate light-node store:
```bash
export FIBRE_HOME="$HOME/.celestia-fibre-mocha-guide"
celestia light init --p2p.network mocha --node.store "$FIBRE_HOME"
```
Initialisation creates a signer. Keep the recovery phrase private. If another
node is running on this machine, stop it or configure different P2P listen
ports before starting this node. For faster initial sync, see
[Syncing from a trusted hash](/operate/maintenance/trusted-hash-recovery), including
its checkpoint trust assumption.
Start the node in one terminal and leave it running:
```bash
celestia light start --p2p.network mocha --node.store "$FIBRE_HOME" \
--core.ip grpc-mocha.pops.one \
--core.port 443 --core.tls \
--rpc.addr 127.0.0.1 --rpc.port 27658
```
This core endpoint is a public community service and may rate-limit requests.
For repeated or large tests, use your own Fibre-capable core endpoint or a
provider with suitable limits. Fibre discovers validator upload/download hosts
from the network; the core address is not a Fibre storage server address.
## Fund the signer and authenticate
In a second Bash terminal, enable pipeline failure reporting and set the same
store and local RPC address:
```bash
set -o pipefail
export FIBRE_HOME="$HOME/.celestia-fibre-mocha-guide"
export NODE_RPC=http://127.0.0.1:27658
export KEY_NAME=my_celes_key
celestia state account-address --node.store "$FIBRE_HOME" --url "$NODE_RPC"
```
Fund the returned address using the [Mocha faucet](https://mocha.celenium.io/faucet).
Check the wallet balance:
```bash
celestia state balance --node.store "$FIBRE_HOME" --url "$NODE_RPC"
```
With celestia-node v0.34.2-mocha, restart the node after funding a signer that
was unfunded when the node started. Otherwise, `fibre.Deposit` can panic during
gas estimation. Stop the node with Ctrl+C in the first terminal, then run the
same start command again.
Wait for header sync to catch up before submitting:
```bash
celestia header sync-state --node.store "$FIBRE_HOME" --url "$NODE_RPC"
```
Check that the reported `height` has reached `to_height` and the initial sync
has a non-zero `end` timestamp. The node should continue following new headers.
Generate a token that permits writes. It also permits the read calls used here:
```bash
export AUTH_TOKEN=$(celestia light auth write \
--p2p.network mocha --node.store "$FIBRE_HOME")
export SIGNER=$(celestia state account-address \
--node.store "$FIBRE_HOME" --url "$NODE_RPC" | jq -er '.result')
rpc() {
curl --fail-with-body --silent --show-error \
--connect-timeout 10 --max-time 180 \
-H "Authorization: Bearer $AUTH_TOKEN" \
-H 'Content-Type: application/json' \
--data-binary @- "$NODE_RPC"
}
```
The examples select `my_celes_key`, the default key created by initialisation.
To use another key, start the node with `--keyring.keyname <key_name>` and set
`KEY_NAME` to that name. `SIGNER` must be that key's public address. The key must
exist in this node's keyring; an address alone does not give the node signing
access. See [Node key management](/operate/keys-wallets/celestia-node-key).
## Query and deposit escrow
Wallet funds pay transaction gas. Fibre escrow pays for blob storage. Keep
some TIA in the wallet when depositing; escrow cannot pay transaction gas.
Amounts use `utia`, where 1 TIA is 1,000,000 utia.
Query this signer's escrow:
```bash
jq -nc --arg signer "$SIGNER" \
'{jsonrpc:"2.0",id:1,method:"fibre.QueryEscrowAccount",params:[$signer]}' | rpc
```
For a new signer, `escrow account not found for signer` is expected. Deposit
2 testnet TIA for the small example below, after confirming the wallet holds
more than 2 TIA:
```bash
jq -nc --arg key "$KEY_NAME" \
'{jsonrpc:"2.0",id:2,method:"fibre.Deposit",
params:[{denom:"utia",amount:"2000000"},{key_name:$key}]}' \
| rpc > deposit.json &&
jq -es '
length == 1 and (.[0] | type == "object" and
(has("error") | not) and has("result") and .result == null)
' deposit.json
```
Success returns `{"jsonrpc":"2.0","id":2,"result":null}`, not a transaction
receipt. Query escrow again and confirm the deposit before proceeding:
```bash
jq -nc --arg signer "$SIGNER" \
'{jsonrpc:"2.0",id:3,method:"fibre.QueryEscrowAccount",params:[$signer]}' \
| rpc > escrow.json &&
jq -es '
length == 1 and (.[0] | type == "object" and
(has("error") | not) and (.result | type == "object" and
(.available_balance | type == "object" and .denom == "utia" and
(.amount | type == "string" and test("^[0-9]+$")))))
' escrow.json &&
jq '.result.available_balance' escrow.json
```
A newly deposited account has these balance fields:
```json
{
"balance": {"denom": "utia", "amount": "2000000"},
"available_balance": {"denom": "utia", "amount": "2000000"}
}
```
These are fields inside `result`, alongside `signer`. Pending withdrawals
reduce `available_balance` before they reduce the total `balance`.
## Submit and save the receipt
Both the full 29-byte namespace and the payload are base64 strings in JSON.
Create a version-0 namespace with the ID `fibre-demo` and a small file:
```bash
printf 'Hello, Fibre!\n' > original.bin
NS=$(python3 -c 'import base64; print(base64.b64encode(bytes(19)+b"fibre-demo").decode())')
DATA=$(python3 -c 'import base64; print(base64.b64encode(open("original.bin","rb").read()).decode())')
jq -nc --arg ns "$NS" --arg data "$DATA" --arg key "$KEY_NAME" \
'{jsonrpc:"2.0",id:4,method:"fibre.Submit",params:[$ns,$data,{key_name:$key}]}' \
| rpc > submit.json &&
jq -es '
length == 1 and (.[0] | type == "object" and
(has("error") | not) and (.result | type == "object" and
(.height | type == "number" and . > 0 and . == floor) and
(.tx_hash | type == "string" and length > 0) and
(.blob_id | type == "string" and length > 0)))
' submit.json &&
jq '.result | {blob_id,height,tx_hash}' submit.json > receipt.json &&
cat receipt.json
```
Stop if any command reports an error or a validation prints `false`. The
`&&` chains run each next command only프로젝트로 돌아가기