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

Add dropaware Sender new type #13242

Closed
mattsse opened this issue Dec 9, 2024 · 3 comments · Fixed by #13495
Closed

Add dropaware Sender new type #13242

mattsse opened this issue Dec 9, 2024 · 3 comments · Fixed by #13495
Assignees
Labels
A-rpc Related to the RPC implementation C-enhancement New feature or request D-good-first-issue Nice and easy! A great choice to get started

Comments

@mattsse
Copy link
Collaborator

mattsse commented Dec 9, 2024

Describe the feature

the way the rpc cache works is a single loop over actions:

match ready!(this.action_rx.poll_next_unpin(cx)) {

disk lookups also reuse that single channel and send actions back to that sender:

let action_tx = this.action_tx.clone();

in the meantime the oneshot response senders wait for that action:

/// The LRU cache for full blocks grouped by their hash.
full_block_cache: BlockLruCache<Provider::Block, LimitBlocks>,
/// The LRU cache for full blocks grouped by their hash.
receipts_cache: ReceiptsLruCache<Provider::Receipt, LimitReceipts>,

these response channels remain in the lru until the action arrives in the mainloop.

This is problematic if the spawned task panics because then nothing is emitted back to the mainloop.
for example if this operation panics

// Only look in the database to prevent situations where we
// looking up the tree is blocking
let block_sender = provider
.sealed_block_with_senders(
BlockHashOrNumber::Hash(block_hash),
TransactionVariant::WithHash,
)
.map(|maybe_block| maybe_block.map(Arc::new));

no action is generated by that task.

we can solve this by introducing a drop aware sender wrapper that sends an action on drop, if not consumed:

like:

let _ = action_tx.send(CacheAction::BlockWithSendersResult {
block_hash,
res: block_sender,
});

struct ActionSender {
  blockhash: B256,
  tx: Option<UnboundedSender<...>
}

impl ActionSender {
  fn send_block(self,...)
}

impl Drop for ActionSender {
  if let Some(tx)
   ... send error
}

Additional context

No response

@mattsse mattsse added C-enhancement New feature or request S-needs-triage This issue needs to be labelled labels Dec 9, 2024
@mattsse mattsse added D-good-first-issue Nice and easy! A great choice to get started A-rpc Related to the RPC implementation and removed S-needs-triage This issue needs to be labelled labels Dec 9, 2024
@coxmars
Copy link

coxmars commented Dec 9, 2024

Hi @mattsse I would like to help you in this one. I will open a PR asap 🫡

@mattsse
Copy link
Collaborator Author

mattsse commented Dec 9, 2024

ty, assigned

@ABD-AZE
Copy link
Contributor

ABD-AZE commented Dec 22, 2024

Hey @mattsse,
Can I work on this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rpc Related to the RPC implementation C-enhancement New feature or request D-good-first-issue Nice and easy! A great choice to get started
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants