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

fix: map txcount resp #1968

Merged
merged 1 commit into from
Jan 30, 2025
Merged

fix: map txcount resp #1968

merged 1 commit into from
Jan 30, 2025

Conversation

mattsse
Copy link
Member

@mattsse mattsse commented Jan 30, 2025

closes #1940

inlines macro and adds the required map

@mattsse mattsse merged commit bb9f516 into main Jan 30, 2025
27 checks passed
@mattsse mattsse deleted the matt/map-tx-count branch January 30, 2025 09:47
@chain-lover
Copy link

chain-lover commented Jan 30, 2025

I see that no loading from cache for get_transaction_count. Is it on purpose or only for fixing the bug?

fn get_transaction_count(&self, address: Address) -> RpcWithBlock<Address, U64, u64> {
let client = self.inner.weak_client();
let cache = self.cache.clone();
RpcWithBlock::new_provider(move |block_id| {
let req = RequestType::new("eth_getTransactionCount", address).with_block_id(block_id);
let client = client
.upgrade()
.ok_or_else(|| TransportErrorKind::custom_str("RPC client dropped"));
let cache = cache.clone();
ProviderCall::BoxedFuture(Box::pin(async move {
let client = client?;
let result = client
.request(req.method(), req.params())
.map_resp(utils::convert_u64 as fn(U64) -> u64)
.map_params(|params| ParamsWithBlock {
params,
block_id: req.block_id.unwrap_or(BlockId::latest()),
});
let res = result.await?;
// Insert into cache.
let json_str = serde_json::to_string(&res).map_err(TransportErrorKind::custom)?;
let hash = req.params_hash()?;
let _ = cache.put(hash, json_str);
Ok(res)
}))
})
}

@mattsse
Copy link
Member Author

mattsse commented Jan 30, 2025

oh you're right,
we don't want to cache txcount because this can change at any point, so we probably should just delete this override

wdyt @yash-atreya ?

tbh not exactly sure why this even exists then @yash-atreya ?

@yash-atreya
Copy link
Member

oh you're right,

we don't want to cache txcount because this can change at any point, so we probably should just delete this override

wdyt @yash-atreya ?

tbh not exactly sure why this even exists then @yash-atreya ?

This caches responses for specific block hashes/number but not for tags.

Can remove it, though

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.

[Bug] CacheProvider does not deserialize get_transaction_count to u64
3 participants