anoma / namada

Rust implementation of Namada, a Proof-of-Stake L1 for interchain asset-agnostic privacy
https://namada.net
GNU General Public License v3.0
2.38k stars 950 forks source link

Restructure codebase for a module-based separation of concerns #2111

Open cwgoes opened 8 months ago

cwgoes commented 8 months ago

At the moment, we split the codebase into separate directories and sub-packages based on technical aspects:

At least personally, I find this separation somewhat confusing, for a few reasons:

I propose for discussion a rework of the structure of the codebase focused on feature modules, e.g.:

Some precedent for this abstraction can be found in the modules system of the Cosmos SDK, which, although it has a lot of boilerplate, implements this basic module abstraction in a reasonably clean manner.

I think that if we do this well, it could make the codebase much easier to navigate, reduce file conflicts, and make it easier to add new modules in the future. Commentary & discussion welcome.

The dependency graph from 0.31.8: deps (generated with cargo depgraph --workspace-only --dedup-transitive-deps | dot -Tpng)

Module dependencies that should be removed:

cwgoes commented 5 months ago

Looking over our current work, particularly @tzemanovic's PRs such as https://github.com/anoma/namada/pull/2312, I thought it would be helpful to try to define the target dependency graph of our internal structure. Based on my understanding, it should look something like this (top -> bottom = deepest dependency -> shallowest):

Untitled-2024-01-12-1601

@tzemanovic @sug0 @batconjurer What do you think? Is this achievable?

cwgoes commented 4 months ago

Updated diagram per discussion with @tzemanovic @batconjurer

updated-diagrams

Agreed on order of operations:

  1. General modularization & separation of modules with a clear interface.
  2. Remove unnecessary WASM usage (specifically in MASP and IBC, which will both change to fully-native VPs).
  3. Reassess and consider further changes.