Skip to content

Conversation

@rayyan224
Copy link
Contributor

@rayyan224 rayyan224 commented Dec 18, 2025

This PR sets up a clean architecture foundation for the account abstraction mempool. It clearly separates domain logic, service orchestration, and infrastructure so the core logic stays pure and easy to reason about.

The goal is to make the mempool more modular, easier to test (mocking Kafka/RPC), and flexible to extend or swap implementations in the future without touching business logic.

- domain/ layer with types, events, mempool, entrypoints
- services/ layer with MempoolEngine and ports (EventSource, UserOperationValidator)
- infrastructure/ layer with Kafka and BaseNode adapters
- factories/ layer with create_mempool_engine wiring

Key changes:
- KafkaEvent renamed to MempoolEvent (domain concept)
- PoolConfig implements Default trait
- Fixed println! to tracing::warn! in mempool
- Applied ports & adapters pattern for testability
- All 20 tests passing
- Updated Cargo.toml to use account-abstraction-core-v2
- Updated imports: KafkaEvent → MempoolEvent, KafkaMempoolEngine → MempoolEngine
- Updated service.rs to use BaseNodeValidator instead of AccountAbstractionServiceImpl
- Removed reputation checks (not yet implemented in v2)
- Updated test mocks to use EventSource instead of KafkaConsumer
- All 12 tests passing

Breaking changes:
- Removed ReputationService integration (will be added back in future)
- Explains domain, services, infrastructure, and factories layers
- Documents ports & adapters pattern with examples
- Includes usage examples and testing patterns
- Provides visual dependency diagram
- Flatten domain/mempool/ folder → domain/mempool.rs (single file)
- Move implementation details to infrastructure/in_memory/
  - OrderedPoolOperation (BTreeSet helper)
  - ByMaxFeeAndSubmissionId (custom Ord for fees)
  - ByNonce (custom Ord for nonces)
- Simplify Mempool trait: add_operation returns Result<(), Error> instead of Option<OrderedPoolOperation>
- InMemoryMempool now in infrastructure layer where it belongs

Benefits:
- Domain is now pure interfaces (trait + PoolConfig only)
- Implementation details hidden in infrastructure
- Consistent with clean architecture principles
- No unnecessary folder nesting
- All 20 tests still passing
@rayyan224 rayyan224 changed the title Chore/tips solid principles refactor Feat Solid Principles Tips And Kafka Engine Dec 19, 2025
@rayyan224 rayyan224 changed the title Feat Solid Principles Tips And Kafka Engine feat: refactor AA mempool into clean architecture layers Dec 19, 2025
@rayyan224 rayyan224 marked this pull request as ready for review December 19, 2025 15:50
@rayyan224
Copy link
Contributor Author

We can delete account-abstraction folder, and rename this one to that in another mr. So the diffs are easier to understand !

@rayyan224 rayyan224 merged commit eca647c into master Dec 19, 2025
10 checks passed
@chunter-cb
Copy link

Follow up pr will clean up/rename this

@rayyan224 rayyan224 deleted the chore/tipsSolidPrinciplesRefactor branch December 19, 2025 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants