Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADR 109: Internalize specific packages to reduce surface area #1485

Merged

Conversation

thanethomson
Copy link
Contributor

@thanethomson thanethomson commented Oct 11, 2023

Partially addresses #1484, based on #1483.

One concern I have is around the possibility that this PR internalizes certain types that are present in publicly accessible function signatures as parameters or return types. This will take some work to address.

  • I've already confirmed that the linter being run on the Cosmos SDK main branch doesn't pick up any missing code-related issues at this point.

This PR currently internalizes about 64k lines of code.


PR checklist

  • Tests written/updated
  • Changelog entry added in .changelog (we use unclog to manage our changelog)
  • Updated relevant documentation (docs/ or spec/) and code comments

Signed-off-by: Thane Thomson <connect@thanethomson.com>
Signed-off-by: Thane Thomson <connect@thanethomson.com>
Signed-off-by: Thane Thomson <connect@thanethomson.com>
Signed-off-by: Thane Thomson <connect@thanethomson.com>
Signed-off-by: Thane Thomson <connect@thanethomson.com>
Signed-off-by: Thane Thomson <connect@thanethomson.com>
Signed-off-by: Thane Thomson <connect@thanethomson.com>
Signed-off-by: Thane Thomson <connect@thanethomson.com>
Signed-off-by: Thane Thomson <connect@thanethomson.com>
Signed-off-by: Thane Thomson <connect@thanethomson.com>
Signed-off-by: Thane Thomson <connect@thanethomson.com>
Signed-off-by: Thane Thomson <connect@thanethomson.com>
Signed-off-by: Thane Thomson <connect@thanethomson.com>
Signed-off-by: Thane Thomson <connect@thanethomson.com>
Signed-off-by: Thane Thomson <connect@thanethomson.com>
Signed-off-by: Thane Thomson <connect@thanethomson.com>
Signed-off-by: Thane Thomson <connect@thanethomson.com>
Signed-off-by: Thane Thomson <connect@thanethomson.com>
Signed-off-by: Thane Thomson <connect@thanethomson.com>
Signed-off-by: Thane Thomson <connect@thanethomson.com>
Signed-off-by: Thane Thomson <connect@thanethomson.com>
Signed-off-by: Thane Thomson <connect@thanethomson.com>
Signed-off-by: Thane Thomson <connect@thanethomson.com>
Signed-off-by: Thane Thomson <connect@thanethomson.com>
Signed-off-by: Thane Thomson <connect@thanethomson.com>
Signed-off-by: Thane Thomson <connect@thanethomson.com>
@thanethomson thanethomson added this to the 2023-Q4 milestone Oct 11, 2023
@thanethomson thanethomson changed the title ADR 109: Internalize non-critical code ADR 109: Internalize packages Oct 11, 2023
@thanethomson thanethomson changed the title ADR 109: Internalize packages ADR 109: Internalize specific packages to reduce surface area Oct 11, 2023
Signed-off-by: Thane Thomson <connect@thanethomson.com>
@thanethomson thanethomson marked this pull request as ready for review October 12, 2023 11:36
@thanethomson thanethomson requested review from a team as code owners October 12, 2023 11:36
Copy link
Contributor

@lasarojc lasarojc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes, which are many but all straightforward, look good to me.
Regarding the use of internal structures as parameters and results in public API, isn't that detected by the linter?

@@ -135,15 +135,17 @@ func (app *localClient) OfferSnapshot(ctx context.Context, req *types.RequestOff
}

func (app *localClient) LoadSnapshotChunk(ctx context.Context,
req *types.RequestLoadSnapshotChunk) (*types.ResponseLoadSnapshotChunk, error) {
req *types.RequestLoadSnapshotChunk,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are formatting this way, then there are other places that should be changed.
I would rather make all such changes together.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see #604.

@thanethomson
Copy link
Contributor Author

Regarding the use of internal structures as parameters and results in public API, isn't that detected by the linter?

It seems not. See https://github.com/cometbft/go-internalized-example

@thanethomson thanethomson merged commit 1511af9 into feature/adr109-reduce-go-api-surface Oct 16, 2023
16 checks passed
@thanethomson thanethomson deleted the thane/adr109/internalize branch October 16, 2023 11:44
@thanethomson thanethomson restored the thane/adr109/internalize branch October 16, 2023 12:02
@thanethomson thanethomson deleted the thane/adr109/internalize branch October 16, 2023 12:04
@thanethomson thanethomson mentioned this pull request Nov 13, 2023
3 tasks
github-merge-queue bot pushed a commit that referenced this pull request Nov 15, 2023
* ADR 109: Internalize specific packages to reduce surface area (#1485)

* consensus: Move into internal

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* evidence: Move into internal

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* inspect: Move into internal

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* state: Move into internal

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* blocksync: Move into internal

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* statesync: Move into internal

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* store: Move into internal

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* libs/async: Move into internal

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* libs/autofile: Move into internal

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* libs/bits: Move into internal

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* libs/clist: Move into internal

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* libs/cmap: Move into internal

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* libs/events: Move into internal

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* libs/fail: Move into internal

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* libs/flowrate: Move into internal

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* libs/os: Move into internal

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* libs/progressbar: Move into internal

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* libs/protoio: Move into internal

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* libs/pubsub: Move into internal

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* libs/net: Move into internal

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* libs/rand: Move into internal

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* libs/service: Move into internal

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* libs/strings: Move into internal

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* libs/sync: Move into internal

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* libs/tempfile: Move into internal

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* libs/timer: Move into internal

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Add changelog entries

Signed-off-by: Thane Thomson <connect@thanethomson.com>

---------

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* ADR 109: Modularize test infra (#1488)

* test/e2e: Split out as separate module

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* test/loadtime: Split out as separate module

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* test/e2e: Remove optimization from Docker image construction

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Ensure that linter covers E2E framework and app

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Update CI linting to cover submodules

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Add changelog entry

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Expand linter coverage to loadtime tool

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Add missing phony entries

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* test/e2e: Sync debug Dockerfile with primary Dockerfile

Signed-off-by: Thane Thomson <connect@thanethomson.com>

---------

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* chore: ADR 109: go mod tidy (#1606)

* go mod tidy

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* go.mod: Remove patch version

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* go.mod: Remove new toolchain directives

Signed-off-by: Thane Thomson <connect@thanethomson.com>

---------

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* ADR 109: Fix mock generation (#1607)

* internal: Fix mockery code generation script paths

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* make mockery

Signed-off-by: Thane Thomson <connect@thanethomson.com>

---------

Signed-off-by: Thane Thomson <connect@thanethomson.com>

---------

Signed-off-by: Thane Thomson <connect@thanethomson.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants