namada icon indicating copy to clipboard operation
namada copied to clipboard

Avoid multiple calls to `process_proposal`

Open grarco opened this issue 1 year ago • 2 comments

Describe your changes

This PR tries to improve the extra calls to process proposal requested by Namada (nothing changes for the requests coming from Comet). More specifically:

  • The more complete process_proposal is now called instead of process_txs
  • The InMemory struct has been expanded with an extra field that caches the requests to process_proposal for a given block so that future calls can be avoided. This cache is cleared when handling a FinalizeBlock request

Indicate on which release or other PRs this topic is based on

v0.40.0

Checklist before merging to draft

  • [x] I have added a changelog
  • [x] Git history is in acceptable state

grarco avatar Jul 02 '24 15:07 grarco

Codecov Report

Attention: Patch coverage is 10.78838% with 215 lines in your changes missing coverage. Please review.

Project coverage is 53.41%. Comparing base (8479d38) to head (5523e05). Report is 4 commits behind head on main.

Files Patch % Lines
crates/node/src/shims/abcipp_shim_types.rs 0.00% 78 Missing :warning:
crates/node/src/shims/abcipp_shim.rs 0.00% 72 Missing :warning:
crates/node/src/lib.rs 0.00% 36 Missing :warning:
crates/node/src/shell/testing/node.rs 0.00% 12 Missing :warning:
crates/core/src/hash.rs 0.00% 5 Missing :warning:
...node/src/shell/vote_extensions/bridge_pool_vext.rs 0.00% 4 Missing :warning:
...rates/node/src/shell/vote_extensions/eth_events.rs 0.00% 4 Missing :warning:
...s/node/src/shell/vote_extensions/val_set_update.rs 0.00% 4 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3473      +/-   ##
==========================================
- Coverage   53.48%   53.41%   -0.08%     
==========================================
  Files         320      320              
  Lines      110000   110160     +160     
==========================================
+ Hits        58832    58840       +8     
- Misses      51168    51320     +152     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Jul 02 '24 15:07 codecov[bot]

@sug0 I've pushed a few more commits to change some things on top of your recommendations:

  • We know have a custom type for the cached elements to avoid caching the txs results when the block is rejected (since we don't need them)
  • The cache is not more a HashMap but a CLruCache to avoid consuming too much memory in cases where the network struggles to make progress and starts producing many block proposals

Let me know if they are ok or it's better to revert the last commits

grarco avatar Jul 04 '24 15:07 grarco