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 memoization for MonadBlockchainCardanoNodeT queries related to the MonadBlockchain instance #228

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

koslambrou
Copy link
Collaborator

Not ready for merge!

Adding a MemoizedCardanoNodeStateQueryT monad transformer, which stores in-memory the responses of the different queries provided by MonadBlockchain. Using the local node's state-query mini protocol is an inefficient way to query information (slow queries, especially if it is spammed with those queries + those queries slow down the other mini-protocols, such as the chain sync mini-protocol).

In its current form, it is a proof of concept to showcase the idea, and see if this is worth adding. Even better if the reviewer has a different viewpoint on how to implement this.

@koslambrou koslambrou requested a review from j-mueller October 22, 2024 23:51
Copy link
Owner

@j-mueller j-mueller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is sensible, to finish it we just need to add protocol parameters to MemoizedCardanoNodeStateQueryResponses. Then we need to refresh the cache periodically (as you said in the comments).

The only question is, how do we detect that a new epoch has started? We could probably just store the start of the next epoch as UTC time, and check against the current time whenever queryProtocolParameters is called.

Or else we say that we discard the MemoizedCardanoNodeStateQueryResponses when we're done building a transaction. That way we don't have to worry about cache expiration, and we still limit the number of actual node queries per transaction to 1.

@koslambrou koslambrou force-pushed the koslambrou/monadblockchaincardanonodet-memoized branch from 67da078 to bb26344 Compare February 17, 2025 13:36
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.

2 participants