Paj Digital Labs
All articles
Web3 & Crypto Tech

Blockchain Finality in Application Databases: Pending Is a Real State

A receipt is evidence of inclusion, not always irreversible settlement. Model provisional records, chain-specific finality and reversal handling before an application treats every new block as permanent.

Paj Digital Labs 4 min read
Hardware security key beside a connected circuit board
Editorial illustration · Web3 & Crypto Tech

An application sees a payment in a new block and marks an invoice settled forever. Later, the source block is replaced or the chain's settlement assumptions change. The database has no state for that possibility because pending was treated as a short animation rather than an accounting condition.

Finality is chain-specific. Some systems provide explicit finalized states; others rely on probabilistic confirmation or settlement through another layer. Your product needs a policy that reflects the actual chain and the value at risk.

Separate observation from settlement

Useful stages include submitted, included, confirmed under policy and finalized where the chain supports that meaning. A failed transaction receipt is not a successful payment, even if it was included.

Store the block number and hash with the transaction and relevant log identity. Height alone does not identify a block uniquely across a reorganisation. Also record chain ID and the contract or asset being observed.

Do not invent a universal confirmation count. An inexpensive digital action and a large financial settlement may justify different risk policies, but those policies need documented assumptions and operational ownership.

Understand the chain's guarantees

Read the network and client documentation for supported finality tags and behaviour. A provider returning latest does not mean finalized. Some layer-two systems have separate sequencer inclusion and settlement considerations.

Track what your source actually reports. A client or provider may lag, omit a tag or expose different semantics than another network. A method with the same name is not proof of identical guarantees.

If your policy relies on an external status API, document that dependency and how you verify it independently during an incident.

Store provisional facts reversibly

  • Raw observed event — Evidence from a specific block and source
  • Provisional projection — Current application view before settlement
  • Settled business transition — Outcome accepted under the documented policy
  • Reversal or correction — Auditable response to invalidated evidence

Keep enough raw identity to reprocess safely, but avoid retaining unnecessary personal data. A projection can be rebuilt; an irreversible external action may not be reversible. That difference should control when you trigger it.

For example, displaying a provisional wallet balance may be reasonable sooner than shipping an expensive physical item. Do not let a shared helper function choose both policies accidentally.

Detect reorganisations

Compare parent hashes as you follow new blocks, and verify previously observed blocks against the canonical chain when appropriate. Subscriptions can disconnect or miss notifications; add reconciliation rather than relying only on a live websocket.

When a block is invalidated, mark its provisional events accordingly and recompute affected projections. Do not simply delete every record without an audit trail if those records influenced business decisions.

Use idempotent event application keyed by the appropriate chain, transaction and log identity. Duplicate delivery is normal and distinct from a replaced block. Handle both explicitly.

Delay irreversible side effects

Emailing a receipt is relatively easy to correct; releasing external funds may not be. Classify downstream actions by reversibility and required settlement confidence.

If the business deliberately accepts provisional payments, state that policy and its loss exposure. Build a response for a payment that later disappears. Calling the transfer "confirmed" without defining the term hides the risk from both users and operators.

An internal balance credit should have a documented reversal mechanism where provisional settlement is allowed. A negative adjustment created after an incident should not be the first time the accounting model considered it.

Reconcile periodically

Check observed payments against canonical receipts and the chosen finality state. Revisit recent provisional records on a schedule that fits the network and policy. Track backlog age and records awaiting verification.

Detect a provider that is several blocks behind by comparing approved independent sources. A healthy HTTP response is not sufficient evidence of current chain state.

When sources disagree, avoid silently selecting whichever one reports completion first. Put the record into an investigation state and preserve the evidence needed to resolve it.

Test before the chain does it for you

Use a controlled local chain or supported test environment to exercise duplicate events, replaced blocks, missing subscriptions and delayed finality. Verify that projections recover and that business actions are not applied twice.

Test restart and backfill from a stored checkpoint. A worker should not assume all events before its current height were processed correctly unless the checkpoint represents durable completion.

Give support a readable state with chain, transaction and policy context. "Included, awaiting settlement under our policy" is more honest than a spinner that never explains the delay.

Finality is part of the data model, not merely a number added to a transaction page. When observation, provisional state and settlement are separate, the application can recover from normal chain behaviour without pretending every new block was a permanent fact.

Paj Digital Labs

The engineering journal of Paj Digital Solutions — hosting, server infrastructure and web engineering, written by the people who run the servers.

Related reading