CKB Pulse

All lessons · CKB node, RPC and indexer · Start here · Glossary

Simulating a real CKB reorg with two devnet nodes over P2PAdvancedFrom one fix

From one fix · Check: right · Checked 2026-11-19

To exercise genuine fork choice on a Dummy devnet, partition two nodes with set_network_active(false) plus remove_node, wait until get_peers is empty on both, then mine a longer competing branch on one node with generate_block. Reconnect with set_network_active(true) and add_node(node_id, /ip4/.../tcp/port), and wait until both nodes report the same get_tip_header hash and the same tx_pool_info tip_hash before checking reorg recovery.

Why it matters: Without a confirmed partition the peer simply syncs the main branch and no competing fork forms. Without waiting for both the tip hash and tx_pool_info tip_hash to converge, reorg checks such as liveness, recovery and dependency rejection run against a node that has not yet switched branches or refreshed its pool.

Pattern

Prefer
rpc::call_at(peer, "add_node", json!([info["node_id"], address]))?;

Taken from the commit, shortened.

Concepts
Testing and devnet, Network and RPC reliability
Evidence
From one fix: from one project, checked against its commit
First seen
2026-10-10
Last changed
2026-10-10
Last checked
2026-11-19
Check against the commit
right: the lesson follows from its commit and still holds in the code today

Sources (2)

More about CKB node, RPC and indexer

All 45 in this topic

Do you maintain a project this lesson came from? Confirm or correct it

Cite this lesson
LusoCryptoLabs, "Simulating a real CKB reorg with two devnet nodes over P2P", CKB lessons, https://pulse.lusocryptolabs.com/learned/node/simulating-a-real-ckb-reorg-with-two-devnet-nodes-over-p2p, CC BY 4.0, last changed 2026-10-10.

Drawn from public commits and checked against the commit each one came from and the project's code today. Read the source before you rely on one. Text under CC BY 4.0: credit LusoCryptoLabs, CKB lessons, with a link to the lesson. Want a lesson changed or removed? Open an issue.