dymint
dymint copied to clipboard
Simplify code to only apply blocks from cache
We have unnecessary branching in our code because we, currently
- On receiving a gossiped block, we apply it or add it to cache (https://github.com/dymensionxyz/dymint/blob/7c1978553888786898df49467fda781c1fcf1b62/block/manager.go#L242-L253)
- On syncing from DA, we apply it or add it to cache https://github.com/dymensionxyz/dymint/blob/df192a9904800b7b1a8bf60a17987cd6630fe5f7/block/retriever.go#L88-L100
Instead, we should just always add blocks to the cache, and then apply from the cache We should remove the path to apply directly It will be less code and more maintainable
handled by #700
Oh yeah, that's a nice improvement in 700 👍 I think an ever better next step will be to only have 1 caller of apply cached blocks
syncer -> cache gossip -> cache some third party: cache -> apply
something like this can also work
I think it would be good if whenever we get a block, we send it to channel
and there is a goroutine to listen on this channel and apply to cache, and he will apply the blocks when the cache has the next one needed
this way we get rid of all mutex related to cache access and simplify the flow
ie. there should only be one applyBlock call in the code
Closing as known problematic area, but need better action items