-
Notifications
You must be signed in to change notification settings - Fork 0
Feat/14 mp 1 mempool data structure design #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
qj0r9j0vc2
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good approach - wrapping Reth instead of reimplementing. BFT policies (min gas price, nonce gap) make sense as the only CipherBFT-specific additions.
Issues
1. StateProvider gets stale
state_provider: StateProviderBox is a snapshot taken at pool creation. This becomes stale after every block, so balance/nonce checks will be wrong. You'll need a way to refresh it - either pass a provider factory and call latest() on each validation, or add a method to swap in a fresh provider after block commits.
2. Commented-out code in config.rs
Lines 57-70 have a bunch of commented config with "TODO: Customize" - either implement these or delete them. Leaving dead code around just adds noise.
3. Unused chain_id
validator.rs:49 stores chain_id but it's never used for anything. If there's a plan for it, add a TODO. Otherwise remove it.
4. Korean comments in error.rs
Mix of Korean and English comments. Pick one for consistency - probably English since the rest of the codebase is English.
Minor stuff
BftPoolPolicycould use#[derive(Default)]and implement reasonable defaults- Consider adding metrics (pool size, rejection rates) for monitoring
- The 100 nonce gap limit is arbitrary - might want to make it configurable
Good stuff
- Test coverage is solid
- Error types are well-structured
- Using Reth's battle-tested pool implementation is the right call
Fix the stale StateProvider issue and clean up the dead code, rest is minor.
CipherBFT Mempool Implementation Review
This document summarizes the CipherBFT mempool components implemented so far.
Implemented Components
1. CipherBftPool Wrapper
CipherBftPool<P>– pool.rsA thin wrapper over the Reth transaction pool, delegating core pool logic and configuration to Reth.
2. CipherBftValidator Wrapper
CipherBftValidator<V>– validator.rsWraps Reth's
EthTransactionValidatorto enable future CipherBFT-specific validation hooks.Methods:
new(): BuildsEthTransactionValidatorinternally and wraps itwrap(): Wraps an existing validator instance3. BFT Policy Validation
validate_bft_policy()– pool.rs (private method called byadd_transaction())Performs CipherBFT-specific checks (minimum gas price, nonce gap) before forwarding transactions to the Reth pool.
BFT-specific policies:
Delegated to Reth:
4. Pool Configuration Mapping
MempoolConfig→PoolConfig– config.rsMaps CipherBFT's
MempoolConfigto Reth'sPoolConfig, exposing price bump and replacement settings.5. Pool Creation Methods
Pool Instantiation – pool.rs
Provides two methods for pool creation:
CipherBftPool::new(): Creates Reth pool internally with all dependenciesCipherBftPool<CipherBftRethPool<Client, S>>chain_spec,client(StateProviderFactory),blob_store,chain_id,mempool_configCipherBftPool::wrap(): Wraps an existing Reth pool instanceP: TransactionPoolpool,mempool_config,state_provider6. Adapter: Pending/Queued Access
CipherBftPoolAdapter– pool.rsProvides helper APIs for batch selection and pending/queued access.
Adapter methods:
get_transactions_for_batch(limit, gas_limit): Select transactions for Worker batchpending_transactions(): Get executable transactionsqueued_transactions(): Get nonce-gap transactionsstats(): Get pool statistics (pending/queued counts)remove_finalized(tx_hashes): Remove finalized transactionsArchitecture Overview
Component Status for CipherBFT Mempool
CipherBftPoolCipherBftValidatorvalidate_bft_policy()in pool.rsnew()andwrap()in pool.rsCipherBftPoolAdapterin pool.rsimpl IntoPoolTransactionInputUsage Flow Examples
Option 1: Create pool with all dependencies (Recommended)
Option 2: Wrap existing Reth pool
Transaction Insertion
Next Steps
1. Worker Integration
Implement actual worker wiring and lifecycle management
2. Test Coverage
Add integration and edge-case tests
3. Production Dependencies
Configure production-ready components
4. Monitoring
Add observability