Skip to content
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

[Feature] Make EthStateCacheService generic over primitives #13049

Closed
klkvr opened this issue Dec 1, 2024 · 1 comment
Closed

[Feature] Make EthStateCacheService generic over primitives #13049

klkvr opened this issue Dec 1, 2024 · 1 comment
Labels
C-enhancement New feature or request S-blocked This cannot more forward until something else changes S-needs-triage This issue needs to be labelled

Comments

@klkvr
Copy link
Collaborator

klkvr commented Dec 1, 2024

Describe the feature

We need to make the cache service generic over node primitives

pub(crate) struct EthStateCacheService<
Provider,
Tasks,
LimitBlocks = ByLength,
LimitReceipts = ByLength,
LimitHeaders = ByLength,
> where

Steps:

  1. Make BlockLruCache, ReceiptsLruCache and HeaderLruCache helpers generic over corresponding primitives.
  2. Add N: NodePrimitives generic to the type and pass it to CacheAction and caches from step 1.
  3. Enforce the provider's primitives to match the configured N in impl blocks, i.e Provider: BlockReader<Block = N::Block, Receipt = N::Receipt>
  4. For now just hardcode the primitives to EthPrimitives in the code creating and spawning the service here:
    fn create<Provider, Tasks>(
    provider: Provider,
    action_task_spawner: Tasks,
    max_blocks: u32,
    max_receipts: u32,
    max_headers: u32,
    max_concurrent_db_operations: usize,
    ) -> (Self, EthStateCacheService<Provider, Tasks>) {
    let (to_service, rx) = unbounded_channel();
    let service = EthStateCacheService {
    provider,
    full_block_cache: BlockLruCache::new(max_blocks, "blocks"),
    receipts_cache: ReceiptsLruCache::new(max_receipts, "receipts"),
    headers_cache: HeaderLruCache::new(max_headers, "headers"),
    action_tx: to_service.clone(),
    action_rx: UnboundedReceiverStream::new(rx),
    action_task_spawner,
    rate_limiter: Arc::new(Semaphore::new(max_concurrent_db_operations)),
    };
    let cache = Self { to_service };
    (cache, service)
    }

Additional context

No response

@klkvr klkvr added C-enhancement New feature or request S-needs-triage This issue needs to be labelled labels Dec 1, 2024
@klkvr klkvr added D-good-first-issue Nice and easy! A great choice to get started S-blocked This cannot more forward until something else changes labels Dec 1, 2024
@klkvr
Copy link
Collaborator Author

klkvr commented Dec 1, 2024

Blocked until #13048

@klkvr klkvr removed the D-good-first-issue Nice and easy! A great choice to get started label Dec 1, 2024
@klkvr klkvr closed this as completed Dec 10, 2024
@github-project-automation github-project-automation bot moved this from Todo to Done in Reth Tracker Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement New feature or request S-blocked This cannot more forward until something else changes S-needs-triage This issue needs to be labelled
Projects
Archived in project
Development

No branches or pull requests

1 participant