Open tkporter opened 6 months ago
The goal of this task is twofold:
Since we want caches to be short lived, find a robust LRU cache library (maybe lru-rs) that ideally also supports TTLs for invalidating entries. Otherwise, implement wrapper logic to add / check TTLs when writing to the cache and when checking if there's a hit.
Given the cache store, optimize the PendingMesage::prepare
step for ISM metadata builders as much as possible
(contract_address, method, serialized_params) -> (serialized_call_result, entry_ttl)
, where method
can be a string that's hardcoded in each MetadataBuilder
implementation (e.g. validators_and_threshold
for the MultisigISM)MetadataBuilder
would likely need two new methods to keep things generic:cache_call_result<T: Serialize, U: Serialize>(contract_address, method, serializable_params: T, call_result: U, ttl: <likely expressed as the timestamp of expiry>);
get_cached_call_result<T: Deserialize>(contract_address, method, serialized_params) -> T;
The implementation should be as generic as possible, to make it easy to add caching to other ISMs / network calls made by the agent in the future. TTLs can be hardcoded to 5 minutes.
On it 🫡
@daniel-savu Just a small clarification, you want to cache the entire ISMs during the building process? 🤔 Asking as doing so requires, everything of each InterchainSecurityModule implementation to be Serializable
Problem
ISMs tend to be pretty static, we can afford to cache ISM configurations for a given address
Solution
To have fewer RPCs when building metadata, cache ISM configs