dymint icon indicating copy to clipboard operation
dymint copied to clipboard

Simplify code to only apply blocks from cache

Open danwt opened this issue 10 months ago • 3 comments

We have unnecessary branching in our code because we, currently

  1. 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)
  2. 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

danwt avatar Apr 17 '24 08:04 danwt

handled by #700

mtsitrin avatar Apr 18 '24 18:04 mtsitrin

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

danwt avatar May 01 '24 10:05 danwt

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

danwt avatar Jul 17 '24 09:07 danwt

Closing as known problematic area, but need better action items

danwt avatar Jan 07 '25 18:01 danwt