-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
rpc: retry latest block via cache in block_with_senders
#11861
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't it a better option to change the block_hash
field of CacheAction::GetBlockWithSenders
to a BlockId
? the EthCacheService
also stores a provider, so can fetch the latest block hash when it processes the cache action.
this would makes more sense, since the EthCacheService
has a queue of cache action events that it processes. the delay between sending the request and processing is only trivially solved by a retry to fetch the hash in this rpc method impl, if solved at all.
reth/crates/rpc/rpc-eth-types/src/cache/mod.rs
Lines 512 to 515 in cb60482
GetBlockWithSenders { | |
block_hash: B256, | |
response_tx: BlockWithSendersResponseSender, | |
}, |
@emhane I get your point, it seems like a good idea to me. I think that in the issue opened by @mattsse he mentioned the fact that retrying was the easiest solution to perform and that would solve most reorg issues but not all:
But I am totally open if it needs to be modified. Maybe I am wrong but I have the following remarks:
reth/crates/rpc/rpc-eth-types/src/cache/mod.rs Lines 49 to 54 in cfd066c
so maybe it requires a bit more changes. Maybe doing the block hash to block id transformation directly in the lookup here as pointed out in the issue description
could be an intermediate solution? But if the block hash to block ID switch is the best solution given everything, more than happy to modify it. |
yeah I think we could use a new command in the cache that looks up by blockid, this way we delay the tag -> hash conversion as late as possible and can prevent a miss due to a reorg |
we can't do that, only hashes map blocks correctly |
@mattsse Let me know if this is what you had in mind, I may have done it a little differently than you thought:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually using the cache with BlockId isn't trivial, I'd like to limit this pr to just the retry which should be fine
cc8adcd
to
9562ea3
Compare
@mattsse Fine just reverted the changes to have only the retry here |
Should close #11859