Introducing a new way to review your PRs.

Read the announcement

celestiaorg / celestia-node

Celestia Data Availability Nodes

View on GitHub

22 documents · Updated Nov 23, 2026

docs / fibre-account-operations

Fibre account operations and state access

Fibre account operations manage the prepaid escrow that pays for Fibre blob storage. The Fibre module reads escrow state, submits deposits and withdrawal requests, and connects those actions to the signer and chain state used by Fibre data operations. This page complements Fibre services.

Account lifecycle

An escrow account is the chain-side balance used to settle Fibre payments. The account API keeps balance reads and account-changing actions in one Fibre surface while the transaction client owns signing and submission.

Escrow account state

An EscrowAccount identifies a signer and reports two views of its funds. Balance is the full escrow amount. AvailableBalance excludes funds that are locked by pending withdrawal requests. A PendingWithdrawal records the requested amount and the time when the amount becomes claimable.

These values let a caller distinguish total escrow from funds that can still pay for new Fibre activity:

StateMeaningCaller use
BalanceTotal funds held in escrowTrack the account's full deposited amount
AvailableBalanceFunds not locked by withdrawal requestsCheck spendable escrow before a Fibre payment
Pending withdrawalFunds waiting for the withdrawal delayShow when requested funds can be claimed

References: fibre/account.go• L16-30 nodebuilder/…/fibre.go• L33-40

Funding and withdrawal operations

Deposit adds a coin amount to the escrow account selected by the transaction configuration. Withdraw creates a withdrawal request rather than making the funds immediately available to the owner. PendingWithdrawals lets the caller observe those requests until their available time.

The normal account flow is:

flowchart LR
    A[Select signer] --> B[Deposit funds]
    B --> C[Escrow balance]
    C --> D[Fibre payment]
    D --> C
    C --> E[Request withdrawal]
    E --> F[Pending withdrawal]
    F --> G[Claimable after delay]

A Fibre submission consumes escrow for the padded upload size after its payment is settled on chain. A caller that submits with no usable escrow receives an error instead of creating an account as a side effect.

References: fibre/account.go• L107-217 fibre/service.go• L89-114 nodebuilder/…/fibre_e2e_test.go• L200-240 nodebuilder/…/fibre_e2e_test.go• L290-319

Signer selection

Read operations take an explicit signer string because they query an account by address. Deposit and withdrawal operations take a TxConfig, which selects the transaction author from the signer address or key name and otherwise uses the node's default account. When both are present, the signer address has priority. The selected signer must be backed by a local key because the transaction client must sign the account message.

The same signer choice must be used when a caller funds an account and later submits Fibre data. This keeps the escrow owner, payment author, and account queried by the caller aligned.

The wider state service keeps this choice separate from Fibre account logic. CoreAccessor resolves the account author and delegates message submission to TxClient, while TxClient handles keyring lookup, fee preparation, and chain submission. Fibre account actions therefore use the transaction configuration as their action boundary rather than handling keyring or fee state themselves.

References: state/…/tx_config.go• L57-88 fibre/account.go• L121-168 fibre/service.go• L73-99 state/core_access.go• L581-598 state/…/tx_client.go• L131-167 state/…/tx_client.go• L306-337

State access boundary

Fibre uses two related state boundaries for different kinds of chain data. The account client queries escrow records through Core and sends account messages through the transaction client. The Fibre state client supplies verified validator and provider state to the Fibre application client on light and bridge nodes.

Account query path

AccountClient is the account-facing read and write boundary. It queries escrow accounts and pending withdrawals through the Fibre query service. It sends deposits and withdrawal requests to the transaction client, which resolves the signer and submits the chain message.

The account client can use a primary Core connection and additional connections. A query tries these connections until one succeeds. An account response that says the signer has no escrow account is different from a transport failure: the first is an account-level absence, while the second means state access did not complete.

sequenceDiagram
    participant Caller
    participant AccountClient
    participant Core as Core query service
    participant Tx as Transaction client
    participant Chain

    Caller->>AccountClient: Query account or withdrawals
    AccountClient->>Core: Query signer state
    Core-->>AccountClient: Account state or error
    AccountClient-->>Caller: Account result

    Caller->>AccountClient: Deposit or request withdrawal
    AccountClient->>Tx: Resolve signer and build message
    Tx->>Chain: Sign and submit transaction
    Chain-->>Caller: Success or error

References: fibre/account.go• L49-104 fibre/account.go• L175-217 state/core_access.go• L151-223 state/…/tx_client.go• L131-167 nodebuilder/…/constructor.go• L69-77

Verified validator state

The Fibre stateclient.Client is a separate boundary for the application client's network view. It reads validator sets at the head or at a requested height, plus the chain identity, from the locally verified header store. It does not fall back to a remote endpoint when a local header is not available. The Core connection is used only for ABCI queries that retrieve a validator's Fibre provider host.

Each host query carries a Merkle proof and is checked against the trusted application hash in the local head. This prevents an untrusted remote state endpoint from choosing the provider host used by Fibre. A failed query status, missing proof, or invalid proof cannot produce a fresh host. The client verifies an empty result as an absence proof and treats the absence of provider information as an authoritative chain result.

The light and bridge state client does not verify Fibre payment promises or report application-node health. Those responsibilities belong to the provider or an application node. On light and bridge nodes, the node builder gives this client to the Fibre application client. Full nodes use the application client's normal state path. This split keeps account transaction access and verified provider discovery as separate responsibilities.

References: fibre/…/stateclient.go• L34-57 fibre/…/stateclient.go• L102-123 fibre/…/stateclient.go• L167-233 fibre/…/stateclient.go• L273-312 nodebuilder/…/constructor.go• L49-66

Host refresh behavior

The state client caches the last known provider host for each validator. Within the refresh window it serves the cached value without another ABCI query. After the window it refreshes the value, and a transient query failure can use the last known host instead of failing the dial. A proof-verified absence is not treated as transient, so it never restores an old host.

Each host query has a time limit. A failed query still opens the refresh window, so repeated callers do not immediately retry a failing endpoint. If no cached host exists, the first failed query returns an error and later calls wait for the refresh window before trying again. This also bounds a stalled Core endpoint instead of allowing it to block provider discovery.

Startup seeds the chain identity and warms the cache from one local header while limiting concurrent host lookups. Prefetch errors do not stop startup, and successful lookups are tied to the same trusted application hash. A warm cache reduces the first-use query burst while keeping all prefetched values tied to one local view of chain state. Concurrent host reads use the same protected cache, so one validator's lookup does not corrupt another's state.

References: fibre/…/stateclient.go• L125-165 fibre/…/stateclient.go• L236-296 fibre/…/stateclient_test.go• L116-197 fibre/…/stateclient_test.go• L209-284 fibre/…/stateclient_test.go• L286-337

Metrics and availability

Account instrumentation measures the time spent in each account operation. Availability depends on the Core endpoint because both account queries and account transactions need chain access.

Account operation metrics

The account client exposes duration histograms for escrow queries, deposits, withdrawal requests, and pending-withdrawal queries. Deposit and withdrawal metrics include the coin denomination. All account metrics include an error class when an operation fails.

The error class groups failures into unavailable, timeout, canceled, or unknown. Metrics are created only when Fibre service metrics are enabled, so dashboards must not treat a missing series as a zero account balance.

MetricOperationExtra attribute
fibre_escrow_query_duration_secondsEscrow account queryError class on failure
fibre_escrow_deposit_duration_secondsDepositDenomination and error class
fibre_escrow_withdraw_duration_secondsWithdrawal requestDenomination and error class
fibre_escrow_pending_withdrawals_duration_secondsPending withdrawal queryError class on failure

References: fibre/account_metrics.go• L11-90 fibre/metrics.go• L13-35 fibre/metrics.go• L77-96

Core endpoint availability

When a node has no Core endpoint, the node builder exposes a stable Fibre module shape backed by a stub. The stub rejects account reads, account writes, and Fibre data operations with a not-available error. It does not return empty account state, so callers can distinguish unavailable chain access from an account with no escrow.

References: nodebuilder/…/constructor.go• L25-46 nodebuilder/…/stub.go• L16-56 fibre/service.go• L20-25

Change checklist

When these files or sections are changed, remember to consider these:

  • Changes to account methods must stay aligned across the public Module, the RPC wrapper, the local module, the service, and the no-Core stub.
  • Changes to signer selection must preserve the priority between SignerAddress, KeyName, and the default account. They must also keep the signer used for escrow actions aligned with the signer used for Fibre settlement.
  • Changes to escrow state fields must preserve the distinction between total balance, available balance, and delayed withdrawals in both JSON responses and callers.
  • Changes to the light and bridge state path must preserve proof checks against the local header application's hash. Do not replace verified host discovery with an unverified remote state read.
  • Changes to ABCI host response handling must preserve non-zero status checks, proof presence checks, proof verification, and the authoritative absence result.
  • Changes to host refresh, query time limits, or startup prefetch must preserve the fallback for a known host and the error for a cold validator. Keep failed lookups from creating an immediate retry loop.
  • Changes to metric names or attributes require matching updates to monitoring rules. Account metric absence must not be read as an account balance of zero.

Important failure modes

TriggerConsequenceGuard
The node has no Core endpointEvery Fibre account operation returns the unavailable errorRun account operations on a node with a configured Core connection
A signer address is not backed by a local keyDeposit or withdrawal cannot be signedUse a signer address or key name that exists in the node keyring
A signer has no escrow account or insufficient available fundsAccount lookup fails or Fibre submission is rejectedDeposit funds first and check AvailableBalance before payment
Funds are in a pending withdrawalThe funds are excluded from available escrow until the delay endsTreat pending withdrawals as locked funds and wait for their available time
A provider host response has no proof, a non-zero status, or an invalid proofFresh provider discovery fails; a cached host is used only when the error is transientKeep the Core proof response complete and tied to the trusted local head
A provider host query fails with no cached hostFibre provider discovery fails for that validator until a later refresh attemptRestore state access and retry after the refresh window
A provider host query stalls or fails with a cached hostThe bounded query returns the last known host, which can be staleRestore state access so a fresh host can be verified
Provider information is absent on chainThe state client returns an authoritative no-provider result instead of using a stale hostRegister the validator's Fibre provider information before relying on discovery
A caller asks a light or bridge client for application-node healthThe state client returns an unsupported error rather than an app health resultUse an application node for provider health checks

Key files

FileWhy to read it
fibre/account.goDefines escrow state and the account query, deposit, withdrawal, and pending-withdrawal flow.
nodebuilder/…/fibre.goDefines the public Fibre account contract and its read/write permissions.
state/…/tx_config.goDefines signer choice and transaction settings used by account actions.
state/core_access.goShows how the wider state service resolves account authors and delegates transactions.
state/…/tx_client.goShows the boundary for signer lookup, fee preparation, and transaction submission.
nodebuilder/…/constructor.goShows how account access and the verified Fibre state client are assembled for each node type.
fibre/…/stateclient.goDefines verified validator and provider-host access for light and bridge Fibre clients, including local-header reads, proof checks, cache, refresh behavior, and unsupported provider-only functions.
fibre/…/stateclient_test.goShows the guarantees for local state reads, proof-query errors, host caching, bounded retries, startup prefetch, concurrent reads, and unsupported provider health checks.
fibre/account_metrics.goDefines account operation duration metrics and their labels.
nodebuilder/…/stub.goShows the behavior when the node cannot reach Core.
nodebuilder/…/fibre_e2e_test.goDemonstrates the account lifecycle, signer selection, escrow debit, and withdrawal delay in an end-to-end flow.