Lesson 0213 min
MEMPOOL · NONCE · REPLACEMENT

Why Do Pending Transactions Queue?

Treat the transaction pool as a waiting room: see how one nonce can be replaced and why invalid transactions wait to be rejected.

OBJECTIVESAfter this lesson, you should be able to:
  • Separate a pending queue from confirmed state
  • Explain the nonce order for one account
  • Watch a replacement keep the sequence number while changing the signed payload
COURSE POSITIONStep 2 of 4
  1. PREVIOUSWho Authorized This Transfer?
  2. CURRENTWhy Do Pending Transactions Queue?

    Treat the transaction pool as a waiting room: see how one nonce can be replaced and why invalid transactions wait to be rejected.

  3. NEXTWhy Must the Same Transactions Have the Same Order?
BEFORE YOU READ

Think about these questions first.

Choose an answer before opening the explanation. You can add anything unexpected to your review list.

Q01Two pending transactions share a nonce. Can both pay?
SHORT ANSWER

A single account nonce can execute only once in sequence. Nodes may temporarily see multiple candidates, but once one enters state, the others with that nonce become invalid.

Compared with your prediction:

After broadcast, a transaction does not immediately change a balance. It enters a node's transaction pool while a block producer decides whether, when, and in what order to execute it. Treat this pool as a public waiting room.

Pending means signed, not applied

A pending transaction has been signed by a wallet, but it is not yet a state transition that every node accepts. It can still fail because of an insufficient balance, a wrong nonce, an invalid signature, or a competing transaction using the same sequence number.

LEDGER SIMULATION虚拟积分 · 无真实密钥
LEDGER 001 · SIGN / VERIFY / APPLY

一笔交易如何变成状态?

交易先被签名和广播,再由节点验证并打包进区块。任何一步不满足规则,余额都不会改变。

当前链高#0TIP GENESIS
待打包交易0Pending
你的 Nonce0下一个可用序号
已确认0Included
被拒绝0Rejected
最终性高度#00 个区块等待
账户状态余额 + Nonce 是可验证状态
Nonce
0
公钥
pk_alice_demo
Nonce
0
公钥
pk_bob_demo
Nonce
0
公钥
pk_you_demo
交易队列0 TXS

还没有交易。先用正确 Nonce 广播一笔转账。

FOCUS EXPERIMENT · POOL交易池与替换

先广播一笔交易,再用相同 Nonce 替换它。比较替换前后的签名摘要和 Pending 状态。

观察提示

先看三张账户余额和 Nonce。签名只授权一组具体字段,节点还要在打包时检查 Nonce、余额和状态规则。

链上区块0 BLOCKS

还没有区块。交易先在本地 Pending,等节点打包。

节点事件1 EVENTS
  1. 01

    创世状态:三个账户各有 1,000 积分,Nonce 从 0 开始。

ACTION HISTORYExperiment timeline
1 state snapshots

Use the slider to return to an earlier step. Continuing from there replaces the later history with a new sequence.

Initial state
View experiment records →

Watch the queue: after broadcast, balances and nonces stay unchanged. Only mining makes the node execute the transactions.

The same nonce can be replaced, but not applied twice

If a pending transaction is no longer what you want, a wallet can broadcast a new version with the same nonce. The state machine can only make that sequence number succeed once; an older version does not cause a second debit after replacement.

Expand: how this step works
replace(pending, nextAmount):
  require pending.status == PENDING
  pending.amount = nextAmount
  pending.signature = sign(pending.fields)

mine(queue):
  for tx in queue:
    if tx.nonce == account[tx.from].nonce and verify(tx):
      apply(tx)
    else:
      reject(tx)

Real chains also use a higher fee to make replacement attractive to block producers. The core constraint remains: one nonce is one slot in an account's state machine.

KNOWLEDGE CHECK

Why does replacing a transaction with the same nonce not debit the account twice?

LESSON RECAPComplete the exercise and knowledge check first