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: Compare local nonce w/ backend to detect invalidated cache #153

Merged
merged 2 commits into from
Aug 22, 2024

Conversation

ryanschneider
Copy link
Contributor

@ryanschneider ryanschneider commented Aug 21, 2024

πŸ“ Summary

If the user submits a tx via some pathway other than our rpc-endpoint (e.g. the public mempool or another private pool) then our cache of the users max nonce was not being invalidated.

β›± Motivation and Context

Steps to reproduce:

  • Send a tx via rpc-endpoint.
  • This causes the nonce to be stored in redis for 24h
  • Send another tx via the public mempool
  • Wait for this mempool tx to be mined
  • Query rpc-endpoint via signed eth_getTransactionCount RPC
  • Note that the old value is still returned.

The fix:

Before returning nonce from cache, we still do a backend request as normal, if it returns a tx count greater than the one derived from our cache we return it instead and invalidate our cache.

πŸ“š References


βœ… I have run these commands

  • make lint
  • make test
  • go mod tidy

@ryanschneider ryanschneider merged commit 401a5eb into main Aug 22, 2024
2 checks passed
@ryanschneider ryanschneider deleted the getTxCount-invalidation branch August 22, 2024 15:35
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