Skip to content

[Core] Preventing import cycles #880

@bryanchriswhite

Description

@bryanchriswhite

Objective

Establish a convention of strictly importing "from below".

Origin Document

Observations made while working on #855 have brought to my attention that we are not strictly adhering to this everywhere, resulting in import cycles waiting to happen. This makes refactoring feel a bit like a minefield which will lead to reluctance to do so.

When one encounters such a case, the resulting MVC has a tendency to explode in size and complexity, making it more difficult to reason through for author and reviewer alike.

Goals

  • Identify upside-down imports
  • Construct a holistic plan for how to restructure effected packages
  • Enact the plan

Deliverable

  • Add a section to the developer documentation
  • Identify all upside-down imports in (sub)module types and members
  • Draft a (holistic) plan for how to restructure effected packages
    • Create shared interfaces in and/or moved shared types to (a) shared package(s)
  • Refactor each effected module, one-by-one
    • P2P
    • Persistence
    • ...

Non-goals / Non-deliverables

  • Identifying or fixing unrelated and non-critical upside-down imports (prioritize (sub)module APIs)
  • Unrelated refactoring; e.g. changing APIs, type definitions, etc.

General issue deliverables

  • Update the appropriate CHANGELOG(s)
  • Update any relevant local/global README(s)
  • Update relevant source code tree explanations
  • Add or update any relevant or supporting mermaid diagrams

Testing Methodology

  • golangci-lint: make lint
  • All tests: make test_all
  • LocalNet: verify a LocalNet is still functioning correctly by following the instructions at docs/development/README.md
  • k8s LocalNet: verify a k8s LocalNet is still functioning correctly by following the instructions here

Creator: @bryanchriswhite
Co-Owners: @dylanlott

Metadata

Metadata

Labels

code healthNice to have code improvementcoreCore infrastructure - protocol relatedtriageIt requires some decision-making at team level (it can't be worked on as it stands)

Type

No type

Projects

Status

Rescope

Relationships

None yet

Development

No branches or pull requests

Issue actions