Skip to content

FIFO Mempool Feature #2

@ancazamfir

Description

@ancazamfir

This issue outlines improvement recommendations for the mempool repository. Recommendations are prioritized to help efforts towards production readiness.

High

CI/CD Pipeline Implementation

There is no automated testing or deployment pipeline:

  • Add github actions workflows for testing, linting, and builds
  • Include security scanning and dependency auditing
  • Implement release process with semantic versioning
  • Add code coverage reporting

Fix Critical Code Issues

There is at least one panic in Arc unwrap operation:

// fifo-mempool/src/app.rs:23
Err(_) => panic!("Cannot unwrap Arc<MempoolEvent> with multiple references")
  • Replace panics with proper error handling

Performance Bottleneck in Transaction Removal

O(n) complexity in remove() function:

// Current implementation rebuilds entire collections
let mut new_txs = VecDeque::with_capacity(state.txs.len() - ignore.len());
let mut new_hashes = HashMap::with_capacity(state.txs.len() - ignore.len());
  • Consider using more efficient data structures (e.g., IndexMap, BTreeMap)
  • Implement lazy deletion or mark-and-sweep approach

Documentation Fixes

Basic documentation errors and missing content

  • Add comprehensive API documentation
  • Create integrator guide

Medium

Comprehensive Testing Strategy

There are limited integration tests, with timing dependencies (sleeps)

  • Add unit tests for all components
  • Replace sleep-based tests with deterministic event-driven tests

Security Hardening

Input validation and DoS protection is not great

  • Add bounds checking for transaction sizes
  • Implement rate limiting for transaction submission (??)

Memory Management Optimization

No TTL or memory bounds for transactions

  • Implement transaction time-to-live (TTL)
  • Add memory usage monitoring and alerts

Low

Observability and Monitoring

Production-ready monitoring

  • Implement Prometheus metrics for mempool statistics
  • Add structured logging with correlating IDs

Network Layer Improvements

  • Implement transaction batching for gossip
  • Add transaction (syntactic) deduplication at mempool actor (keep mempool hash together with app hash)

Configuration Management

Limited configuration flexibility

  • Add environment variable support
  • Implement configuration validation at startup
  • Include configuration templates and examples

Development Tooling

No development workflow automation

  • Add pre-commit hooks for formatting and linting
  • Include rust-toolchain.toml for version consistency

Future Enhancements

  • Advanced Mempool Features
  • Transaction prioritization based on fees or other criteria
  • Support for transaction dependencies and ordering (not FIFO anymore)
  • Scalability: multi instance, sharding, etc.
  • Protocol versioning
  • Integration
  • gRPC/REST API for external system integration
  • notifications for transaction lifecycle events

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions