Docs Técnicas
atlas-mempool
atlas-mempool is the transaction staging crate for the Rust workspace. It receives statelessly valid signed transactions before they are proposed, deduplicates them, tracks pending status, and exposes candidate selection for block production.
Summary
atlas-mempool is the transaction staging crate for the Rust workspace. It receives statelessly valid signed transactions before they are proposed, deduplicates them, tracks pending status, and exposes candidate selection for block production.
The crate uses an in-memory local mempool behind a small facade. A previous Redis-backed mempool path was removed because it did not support the sealing workflow required by block production and added O(n) remote scans to hot-path operations.
Why This Crate Exists
- keep transaction staging separate from ledger execution
- give node and admin surfaces one place to enqueue signed transactions
- prevent obvious duplicates and nonce conflicts before proposal construction
- support local development and node runtime transaction staging behind the same API
Current Role In The Workspace
atlas-mempool currently owns four main concerns:
- a unified
Mempoolfacade - local in-process transaction storage
- admission checks such as stateless validation and timestamp windows
- batch-oriented lifecycle operations such as sealing, marking pending, cleanup, and removal
It is not the final authority for transaction validity. The ledger still performs deeper validation later. The mempool acts as the admission and staging layer before proposal creation or relay.
Public Surface
Top-Level Modules
core
Main Public Reexports
MempoolMempoolValidationPolicyatlas_common::ports::MempoolPort
Important Types
MempoolMempoolValidationPolicyLocalMempool
Important Trait Implemented
atlas_common::ports::MempoolPortforMempool
Key Modules
- `lib.rs`: public facade and
MempoolPortimplementation - `core/mempool.rs`: unified mempool wrapper and validation policy
- `core/mempool/local.rs`: in-memory backend with pending tracking, sealing, cleanup, and committed-cache behavior
- `tests/integration.rs`: integration tests for local behavior and rejection of the removed Redis mempool backend
Inputs And Outputs
Inputs
SignedTransactionvalues from REST, gRPC, admin, or runtime replay flows- mempool validation policy for local deployments
Outputs
- accepted or rejected mempool admissions
- candidate batches for proposal construction
- pending markers for in-flight transactions
- duplicate detection results
- cleanup results for expired or stuck transactions
Internal Dependencies
Workspace Dependencies
atlas-common
This crate sits just above the shared types layer and below the node and ledger layers.
External Dependencies That Shape The Design
sha2andhexfor transaction hashingtokiofor async operationsasync-traitfor port implementation plumbing
Used By
These packages depend directly on atlas-mempool today:
atlas-node-adminatlas-ledgeratlas-node
Observed usage in the codebase includes:
- `runtime/builder.rs`: node runtime builds a mempool with configurable validation policy
- `transactions.rs`: REST transaction submission checks pending nonce conflicts and then adds to mempool
- `service.rs`: ledger gRPC service performs mempool admission after signature and nonce checks
- `handlers/kyc.rs`: admin KYC flows enqueue signed transactions into the mempool
- `handlers/institutions.rs`: admin institution issuance flows use nonce conflict checks and enqueue to the mempool
Backend Model
Local Backend
`local.rs` keeps transactions in process memory and adds some extra behavior:
- configurable timestamp-window enforcement
- pending tracking by tx hash
- a committed-cache with bounded history
- sealed batches for block producer handoff
- sender-focused pending queries such as
get_pending_by_senderandget_max_pending_nonce_by_sender
Validation Model
The mempool performs admission checks, not full ledger execution checks.
The current admission path includes:
SignedTransaction::validate_stateless()- timestamp window enforcement
- duplicate prevention against the current pool
- duplicate prevention against a committed-cache
The local strict timestamp policy is roughly now - 300 to now + 300.
For tests, the local backend can disable timestamp enforcement through MempoolValidationPolicy::test_relaxed().
Testing
The crate has:
- module-local tests in the facade and backend implementations
- `integration.rs`: local integration coverage
The test coverage exercises:
- local default construction
- relaxed validation policy for tests
- duplicate handling
- pending and cleanup behavior
- Redis mempool backend rejection
Risks Or Design Tension
Admission Is Not Final Validation
The mempool runs stateless checks and lightweight timing rules, but authoritative validation still happens later in the ledger pipeline. That is the correct layering, but it can confuse readers if they expect mempool acceptance to imply full validity.
Open Questions
- should the sealed-batch concept stay local to the mempool crate, or move upward into block production orchestration
Relevant Files
- `Cargo.toml`
- `lib.rs`
- `mempool.rs`
- `local.rs`
- `integration.rs`
- `runtime/builder.rs`
- `transactions.rs`
- `service.rs`
- `handlers/kyc.rs`
- `handlers/institutions.rs`