[Draft] refactor(tx-pool): unify transaction lifecycle under sharded authority - #5316
[Draft] refactor(tx-pool): unify transaction lifecycle under sharded authority#5316zhangsoledad wants to merge 3 commits into
Conversation
a254415 to
ad355d6
Compare
|
Security review completed against The blocking themes are: avoid routed lock acquisition while an all-shard read cut is live; fence or version all causal sources across chain receipt capture and apply; distinguish reserved ApplySequence values from a committed-prefix watermark; and make clear-current-pool use execution-time snapshot state or reject stale intent.
|
This is a known open issue: C2 is tracked in HELD_SHARD_CUT_AND_POLICY_READ_COHERENCE, one of eight open terminal-correctness clusters. We are first minimizing the architecture and retiring the composite/alternate routes so the lock graph and correctness TCB are smaller. We will then reopen C2 against the frozen simplified source and close it root-wise with deterministic production-bound, no-sleep interleaving evidence and a lock-order DAG. Until then, C2 and terminal correctness remain explicitly open; we will not apply a finding-specific patch. |
[!IMPORTANT]
Start here
develop, transaction lifecycle facts live in several mutablesubsystems. Individual bugs can be patched, but isolated patches cannot prove
the cross-route ownership and atomicity invariant.
TxPoolAuthorityto own every retainedtransaction. Mutation is split into non-mutating validation and planning,
one total exact-shard
Apply, and effects after authority release.disjoint physical support; genuinely coupled facts are ordered only at their
smallest authoritative cut. There is no ordinary global/outer serial
fallback.
and review boundaries—not final acceptance.
For a first pass, read
ARCHITECTURE.mdsections 1–4,
state.rs, andshard.rs. The three initial questions are:Why this needs an architectural change
CKB tx-pool ownership interacts with dependency resolution, duplicate and
conflict identity, RBF closure, Pending/Gap/Proposed state, resource and worker
accounting, relay effects, reorg, template publication, persistence, and
shutdown.
On
develop@17d7db5bb423a1b2177e14a132a41d5a91a515f3, retained lifecyclestate is distributed across
VerifyQueue,OrphanPool,TxPool / PoolMap,workers, and asynchronous follow-up paths. Those locations have different
locks and transition rules.
flowchart LR I[Ingress] --> V[VerifyQueue] V --> W[Resolve / verify workers] W --> O[OrphanPool] W --> P[TxPool / PoolMap] R[RBF / reorg / clear] --> O R --> P V --> Q{One atomic owner + graph + charge + effect cut?} O --> Q P --> Q Q --> N[Not established by isolated local patches]A concrete witness is
PoolMap::check_and_record_ancestorsin the frozendevelopbaseline. Its FIXME records a path where an RBF candidate can removeconflicts before a later ancestor-limit failure, requiring rollback. The
retained regression
uak_develop_stale_parent_eviction_shape_is_total_rejection_without_mutationrequires that legal shape to reject without partial mutation.
Prechecking that condition can fix that witness. It does not prove the same
property for every duplicate, RBF, dependency, capacity, reorg, cancellation,
and effect exit. The precise claim of this PR is therefore:
Proposed design constraints
TxPoolAuthority.entries, keyed by full transaction hash, is intended to bethe sole transaction-lifecycle owner. Scheduler rows, dependency relations,
indexes, resource totals, queues, and effect records should remain projections
or move-owned capabilities—not secondary transaction owners.
flowchart LR I[Bounded input] --> V[Validate<br/>no mutation] V --> C[Resolve / verify<br/>outside authority] C --> P[Plan<br/>one coherent cut] P --> R[Preflight<br/>allocation + capacity + OCC] R -->|stale / reject / pressure| T[Typed outcome<br/>no owner mutation] R --> A[Apply<br/>smallest exact shard cut] A --> X[Release authority<br/>move-owned receipt] X --> E[Relay / callback / reply / I/O] classDef commit fill:#dbeafe,stroke:#1d4ed8,stroke-width:2px; class A commit;The transition rule reviewers should verify is: fallible policy and allocation
work finishes before mutation;
Applyrevalidates freshness and commits owner,projection, accounting, clocks, and required effects atomically; external I/O
runs afterward and cannot veto the commit.
Why true sharding matters
The current implementation uses 64 routed authority shards. The intended rule
is that ordinary mutations acquire the exact canonically ordered support
derived from their typed delta. Physical separation alone does not imply
semantic independence.
flowchart TB A[Transaction A] --> SA[Exact support A] B[Transaction B] --> SB[Exact support B] SA --> AA[Apply cut A] SB --> AB[Apply cut B] AA --> O[May overlap when supports commute] AB --> O C[Coupled transaction C] --> U[Union of shared authoritative facts] D[Coupled transaction D] --> U U --> M[One minimum canonical cut] G[Chain / generation / close] --> X[Rare named lifecycle barrier]The architectural value is the combination, not the number
64or a specificRust wrapper:
The number of shards and current file layout are implementation choices.
Alternative designs are welcome if they establish the same cross-route
ownership, atomicity, bounded-work, and disjoint-progress properties.
Current status and non-claims
developreconciliation and history compression0production routes8clusters /11candidatesdevelopThe committed control head is
0e0678282db0defd4b21bdea35279ab26d0b88d2; thefrozen production subject is
51d282345d1d83119c46cdde8f1115f14561b4acwithtree
1e19719c764c7349a178d7ac0b7bf4999542966f.Historical observation, not current-head evidence:
make integrationatarchive commit
0d553de760aa71a3b42dbc8f81f27ddcc775be4cstopped at66 passed / 1 failed / 110 not started;RbfConcurrencybecame unreachablebefore its first
tx_pool_infoobservation. The relevant productionimplementation was later transferred unchanged to
51d282345, but the fullsuite has not been rerun on that identity. Standalone and four-spec replays
passed, so the root cause remains open.
This PR does not currently claim global terminal correctness, measured
performance leadership, final trusted-code-surface minimality, final security
completion, merge readiness, or that
developis literally impossible to fix.How to review this PR
Please review the three intent-separated commits instead of starting from the
unified diff:
51d282345— atomic true-shard architecture implementation;33c7b1b26— post-merge terminal-audit checkpoint and evidence;0e0678282— repository-owned Primary control, stable agent instructions,and live-state binding.
Deeper correctness review
Start from the
TP-OWN-001,TP-COMMIT-001,TP-POOL-001, andTP-EFFECT-001rows inREVIEW_GUIDE.md, then inspect:plan.rsandauthority/plan/*;resources.rs;effect.rs;FINDINGS_LEDGER.json.Ask:
after release?
Useful focused witnesses
uak_duplicate_and_promotion_never_create_second_owneruak_dropped_prepared_apply_is_semantically_mutation_freeuak_rbf_replaces_the_complete_descendant_closure_atomicallyuak_terminal_outcome_and_effect_commit_togetheruak_two_compatible_direct_candidates_overlap_inside_their_owner_cutsuak_disjoint_accepted_local_removals_overlap_inside_the_real_runtime_cutruntime_disjoint_malformed_peer_revocations_overlap_under_outer_readDeep dive: Ready, dependency, and RBF
Read
scheduler.rs,dependency.rs,plan/membership.rs, andplan/membership/rbf.rs. Start fromTP-RBF-001,TP-DEP-001, and thematching entries in
FINDINGS_LEDGER.json.Deep dive: chain, template, persistence, and shutdown
Read
plan/chain_transition.rs,template_driver.rs,read.rs,topology.rs,and
service.rs. Check that lifecycle fences remain explicit and that rarebarriers do not spread into ordinary mutation.
Compatibility decisions
The compatibility intent is to preserve CKB consensus, CKB-VM script
semantics, hardfork selection, and wire transaction semantics. The public Rust
API change is an intentional major-version migration. Persistence v2 accepts
legacy v1 input; legacy configuration is translated through validated
defaults. No compatibility facade may recreate mutable transaction or policy
authority.
Why the PR is large—and how it will get easier to review
The ownership replacement necessarily crosses ingress, validation,
dependencies, membership, resources, effects, reads, templates, reorg, and
shutdown. A half-migrated state would retain a second semantic engine or a
serial fallback—the two outcomes this design is intended to remove.
Diff inventory against the frozen develop base
The committed branch currently changes
343files (+161,757 / -9,946). Thereview slices below are mechanically classified by path:
The first commit carries the architecture. The next two commits are primarily
audit, review, and repository-control material. This table explains the size;
it does not claim that the remaining production surface is already minimal.
The current size is not proposed as the final maintenance cost. Before moving
out of Draft, I will:
artifacts;
developonly after correctness and static qualification.Feedback requested now
Please comment early on:
The goal of this Draft is not to make reviewers accept a permanently enormous
cognitive surface. It is to let design feedback shape the architecture while
that surface is still being reduced.