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 / transaction-state

Transaction submission and account state

The state service gives the node one boundary for account identity, chain state, and transaction submission. It reads balances and staking data from Core, signs transactions with local keys, and submits pay-for-blobs (PFB) transactions through the Core transaction client. This page complements Blob services and Blob submission and retrieval.

State service boundary

The state service connects callers to account data and transaction actions without requiring each caller to manage Core connections or signing. It supports the blob service, RPC clients, and command-line actions through the same account and transaction rules.

State operations

Read operations expose the node account, balances, delegation data, and rewards. Write operations create chain messages for transfers, staking changes, fee grants, and PFB submission. Each write returns the chain transaction result after the transaction client submits it.

The PFB operation accepts prepared blobs and validates their namespaces before it sends them. It resolves the transaction author from the transaction options, then returns the transaction result and inclusion height to the blob service. The state command interface exposes the same read and write boundary for operators. See Blob submission and retrieval for the wider blob flow.

References: state/core_access.go• L49-54 state/core_access.go• L151-223 state/core_access.go• L225-231 state/core_access.go• L310-559 nodebuilder/…/state.go• L27-71 state/core_access_test.go• L35-105

Account and validator addresses

An account address identifies a signer and a balance owner. A validator address identifies a staking target. Public address values cross the API boundary as Bech32 strings, while the state service uses the matching account or validator role for each action.

State queries use the default account unless a query accepts another account address. A transaction can select a different local signer. The signer authorizes the transaction, while the validator remains the staking target. Command-line actions reject an address when its kind does not match the requested operation.

References: state/state.go• L23-59 state/core_access.go• L225-231 state/core_access.go• L321-328 state/core_access.go• L350-357 state/core_access.go• L428-435 state/core_access.go• L462-505 nodebuilder/…/state.go• L464-495

Account identity and key management

The node stores signing keys in its local Cosmos keyring. The state service resolves the configured default key at startup and uses its address as the default account for state reads and transactions.

Keyring signer

The keyring is the source of signing authority. Callers do not send private keys through the state or blob APIs. They select a local key by name or provide the address of a local key in transaction options.

Signer selection follows this order:

  1. A configured signer address selects the transaction author.
  2. Otherwise, a configured key name selects a local key.
  3. Otherwise, the default key and address are used.

When a caller selects an address, the transaction client maps that address back to its keyring name before signing. This keeps the public address choice and local signing record aligned.

References: state/core_access.go• L88-123 state/core_access.go• L581-598 state/…/tx_client.go• L311-343 state/…/tx_config.go• L75-87

Transaction options

TxConfig carries the choices that affect transaction authorship and fees. It can select a signer or key, a fee granter, gas, a gas price, a maximum estimated gas price, a maximum gas limit, and a transaction priority.

Nil options are treated as default options at each public write boundary. An unset gas limit or gas price asks the transaction client to estimate the missing value. A caller-set gas price remains distinct from an estimated price, including when the caller sets the price to zero.

The configuration can cross JSON-RPC as a serialized object. Its signer, fee, gas, priority, and explicit-price choices must survive that round trip.

References: state/…/tx_config.go• L15-52 state/…/tx_config.go• L75-190 state/…/tx_config.go• L201-271 state/state.go• L62-92 state/core_access.go• L154-160 state/core_access.go• L310-317 state/core_access_test.go• L632-720

Chain state access

The Core-backed accessor reads chain state through the node's current header and verifies the result against the committed application state. This protects callers from treating an unproved or stale response as an account balance.

Core readiness

State startup waits for Core to return node information and produce its first block. It then checks that the endpoint reports the configured network. A reachable endpoint on the wrong network, or an endpoint that remains halted before its first block, does not become the node's state source.

The accessor creates query clients for staking, distribution, fee grants, and ABCI state. The transaction client uses the primary Core endpoint and can receive additional endpoints for transaction traffic.

References: state/core_access.go• L126-143 state/core_access.go• L610-641 state/…/tx_client.go• L414-456 state/core_access_test.go• L174-181

Balance visibility

Balance reads use the state committed before the current header's block. Therefore, a transaction included at height H becomes visible to this balance view after height H+1 is committed. This rule matters when a caller checks the account after a successful transaction.

The accessor requires a proof for both present and absent balances. A valid absence proof becomes a zero balance. An empty response without proof, or a response whose proof does not match the value, is rejected.

References: state/core_access.go• L229-307 state/core_access_test.go• L521-528 state/core_access_test.go• L590-629

Transaction submission

The transaction client joins the local keyring to the Core transaction endpoint. It prepares the signer, fee payer, gas, and gas price before it asks the application client to sign and submit the transaction.

Message transactions

For transfers, staking actions, and fee-grant actions, the state service creates the chain message after it validates amounts and addresses. The transaction client then estimates or applies gas and fee settings, validates the resulting fee, and submits the message.

Fee grants let one account pay for another account when the chain has a valid allowance. A zero grant amount means an unlimited spend limit. Nil or negative grant amounts are rejected before submission.

References: state/core_access.go• L310-559 state/core_access_grantfee_test.go• L35-75 state/…/tx_client.go• L131-167

Pay-for-blobs flow

The PFB path turns prepared blobs into one synchronous transaction. The state service checks the request and resolves the author. The transaction client checks the signer account, calculates gas and fee settings, applies an optional fee granter, signs with the local keyring, and submits through Core.

The diagram shows the main boundaries from a blob request to its committed transaction result.

flowchart LR
    A[Blob service] --> B[State service]
    B --> C[Validate blobs and resolve signer]
    C --> D[Read signer account]
    D --> E[Estimate or apply gas and fee]
    E --> F[Validate fee]
    F --> G[Sign with keyring]
    G --> H[Submit through Core]
    H --> I[Return transaction result and height]

The default signer can use the configured PFB worker queue. A non-default signer submits with its own account and does not use that default-account queue. A successful chain code is required for a successful PFB; a transaction response with a non-zero application code is not a successful submission.

References: state/core_access.go• L151-222 state/…/tx_client.go• L169-293 state/core_access_test.go• L276-355 state/core_access_test.go• L396-518

Gas and fee estimation

The client uses caller values when they are set and estimates only the missing gas or gas price. PFB gas depends on the submitted blobs. Message gas uses the application estimator. When the caller leaves the gas price unset, transaction priority guides the recent chain price range used for estimation.

An estimated gas price or gas limit above its configured maximum stops submission. Blob submissions use a caller-set maximum gas limit because their normal limit grows with blob size. Negative, non-finite, or overflowing fee values also stop submission before fee construction. Insufficient-fee errors identify whether the caller set the gas price or the client estimated it.

An optional estimator service supplies gas price data. Its connection can use TLS and retries temporary unavailable responses. The client creates the connection without waiting for the estimator to become ready. The first estimator request performs the service call when a transaction needs an estimated gas price.

References: state/…/tx_client.go• L86-115 state/…/tx_client.go• L295-305 state/…/tx_client.go• L345-412 state/…/tx_config.go• L15-30 state/…/estimate_test.go• L24-165

Nodebuilder state module

The nodebuilder state module assembles the keyring, transaction client, and Core-backed accessor into one lifecycle-managed service. It gives the blob module and RPC layer the same account identity and submission path.

Module assembly

When Core is configured, node construction creates the transaction client and state accessor. The transaction client receives the primary Core endpoint and any configured extra endpoints. The blob module receives the state submitter, so blob code does not own signing, account lookup, fee handling, or Core submission.

References: nodebuilder/…/module.go• L20-54 nodebuilder/…/core.go• L16-58 nodebuilder/…/module.go• L27-45 nodebuilder/module.go• L42-54

Core-disabled mode

When no Core endpoint is configured, node construction still exposes a state module shape. Its operations return ErrNoStateAccess instead of pretending that account or transaction access is available. A node needs a reachable Core endpoint and the configured local key to enable state access.

References: nodebuilder/…/module.go• L31-53 nodebuilder/…/stub.go• L15-51 nodebuilder/…/flags.go• L19-35

Submission modes

State configuration controls whether PFB submission is direct or uses worker accounts. Direct submission avoids a queue. A single worker supports queued default-account submission. Several workers allow parallel submission but can change inclusion order.

Worker account settingSubmission behavior
0Submit directly without a queue.
1Use a queue with the default signer.
Greater than 1Use several worker accounts for parallel submission. Request order is not guaranteed.

Worker setup can use key names that already exist in the keyring, including unfunded accounts. This lets startup prepare worker identities before those accounts have chain funds.

References: nodebuilder/…/config.go• L18-32 nodebuilder/…/flags.go• L29-47 state/…/tx_client.go• L278-283 state/core_access_test.go• L276-394

Change checklist

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

  • Keep state.Module, the Core-backed accessor, the no-Core stub, the RPC permissions, and the blob submitter contract aligned.
  • Preserve signer precedence across TxConfig, keyring lookup, transaction author resolution, and transaction-client key selection.
  • Preserve the distinction between the default-account worker queue and custom-account submission.
  • Keep nil transaction options safe across every state write path and direct transaction-client call.
  • Preserve explicit zero gas prices and the difference between caller-set and estimated gas prices during JSON serialization.
  • Keep the maximum estimated gas-price and gas-limit guards aligned with message and PFB submission rules.
  • Preserve the one-block balance visibility delay and proof checks for both present and absent balances.
  • Keep fee-grant validation aligned with the zero amount meaning of an unlimited allowance.
  • Keep command-line account and validator address parsing aligned with the state API's address types.

Important failure modes

TriggerConsequenceGuard
The default key is missingState construction or startup failsRestore the key or configure an existing local key
Core is absent or reports the wrong networkState calls fail or the accessor does not startConfigure a reachable Core endpoint for the expected network
Core has not produced its first blockState startup waits and then failsFix the halted or catching-up Core node
A signer address has no local keyThe transaction cannot be signedUse an address backed by the node keyring
A PFB has no blobs or uses a disallowed namespaceThe request is rejected before submissionSend at least one valid blob
Estimated gas price exceeds the configured maximumSubmission stops before broadcastSet an acceptable limit or a suitable fixed price
Estimated or configured gas exceeds the configured maximumSubmission stops before broadcastRaise the gas limit or reduce the transaction size
A fee is negative, non-finite, or too largeFee construction is rejectedUse finite non-negative values within the fee range
A balance response has no valid proofThe balance query is rejectedRequire a matching value or absence proof
More than one worker submits in parallelInclusion order can differ from request orderUse direct or single-worker submission when order matters
A balance is queried at the inclusion heightThe old account state can be returnedWait for the next committed block
The estimator is unavailableTransactions needing an estimated gas price cannot proceedUse a fixed gas price or restore the estimator
A command receives the wrong address kindThe operation is rejectedUse an account address for account actions and a validator address for staking actions

Key files

FileWhy to read it
state/core_access.goDefines the state boundary for balances, addresses, staking actions, fee grants, and PFB submission.
state/state.goDefines the public address and transaction types that cross the state API boundary.
state/…/tx_client.goShows signer lookup, fee preparation, estimation, Core submission, and worker selection.
state/…/tx_config.goDefines signer, fee, gas, priority, default, and JSON configuration behavior.
nodebuilder/…/module.goShows how state access joins the node lifecycle and how no-Core mode behaves.
nodebuilder/…/core.goShows how the Core accessor and transaction client are assembled.
nodebuilder/…/module.goShows how the blob service receives the state submitter.
nodebuilder/…/state.goShows the operator-facing state commands and account-versus-validator address checks.
blob/service.goShows how public blob submission reaches the PFB boundary.
state/core_access_test.goDemonstrates network checks, balance proofs, nil options, custom signers, and worker submission contracts.
state/core_access_grantfee_test.goDemonstrates fee-grant amount validation and the unlimited zero amount.
state/…/estimate_test.goDemonstrates fixed and estimated gas values, priorities, and maximum gas and gas-price checks.