8000 feature: Reduce Go API surface area (ADR 109) by thanethomson · Pull Request #1605 · cometbft/cometbft · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feature: Reduce Go API surface area (ADR 109) #1605

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

Merged
merged 8 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
8000
  •  
  •  
  •  
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Split E2E test framework and E2E test app out as separate Go modules
([\#1484](https://github.com/cometbft/cometbft/issues/1484))
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- `[blocksync]` Move to `internal`
([\#1485](https://github.com/cometbft/cometbft/pull/1485))
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- `[consensus]` Move to `internal`
([\#1485](https://github.com/cometbft/cometbft/pull/1485))
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- `[evidence]` Move to `internal`
([\#1485](https://github.com/cometbft/cometbft/pull/1485))
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- `[inspect]` Move to `internal`
([\#1485](https://github.com/cometbft/cometbft/pull/1485))
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- `[libs/autofile]` Move to `internal`
([\#1485](https://github.com/cometbft/cometbft/pull/1485))
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- `[libs/bits]` Move to `internal`
([\#1485](https://github.com/cometbft/cometbft/pull/1485))
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- `[libs/clist]` Move to `internal`
([\#1485](https://github.com/cometbft/cometbft/pull/1485))
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- `[libs/cmap]` Move to `internal`
([\#1485](https://github.com/cometbft/cometbft/pull/1485))
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- `[libs/events]` Move to `internal`
([\#1485](https://github.com/cometbft/cometbft/pull/1485))
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- `[libs/fail]` Move to `internal`
([\#1485](https://github.com/cometbft/cometbft/pull/1485))
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- `[libs/flowrate]` Move to `internal`
([\#1485](https://github.com/cometbft/cometbft/pull/1485))
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- `[libs/net]` Move to `internal`
([\#1485](https://github.com/cometbft/cometbft/pull/1485))
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- `[libs/os]` Move to `internal`
([\#1485](https://github.com/cometbft/cometbft/pull/1485))
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- `[libs/progressbar]` Move to `internal`
([\#1485](https://github.com/cometbft/cometbft/pull/1485))
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- `[libs/protoio]` Move to `internal`
([\#1485](https://github.com/cometbft/cometbft/pull/1485))
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- `[libs/pubsub]` Move to `internal`
([\#1485](https://github.com/cometbft/cometbft/pull/1485))
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- `[libs/rand]` Move to `internal`
([\#1485](https://github.com/cometbft/cometbft/pull/1485))
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- `[libs/service]` Move to `internal`
([\#1485](https://github.com/cometbft/cometbft/pull/1485))
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- `[libs/strings]` Move to `internal`
([\#1485](https://github.com/cometbft/cometbft/pull/1485))
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- `[libs/sync]` Move to `internal`
([\#1485](https://github.com/cometbft/cometbft/pull/1485))
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- `[libs/tempfile]` Move to `internal`
([\#1485](https://github.com/cometbft/cometbft/pull/1485))
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- `[libs/timer]` Move to `internal`
([\#1485](https://github.com/cometbft/cometbft/pull/1485))
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- `[libs/async]` Move to `internal`
([\#1485](https://github.com/cometbft/cometbft/pull/1485))
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- `[state]` Move to `internal`
([\#1485](https://github.com/cometbft/cometbft/pull/1485))
3D11
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- `[statesync]` Move to `internal`
([\#1485](https://github.com/cometbft/cometbft/pull/1485))
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- `[store]` Move to `internal`
([\#1485](https://github.com/cometbft/cometbft/pull/1485))
13 changes: 11 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ jobs:
name: golangci-lint
runs-on: ubuntu-latest
timeout-minutes: 8
strategy:
matrix:
# One entry per distinct Go module/submodule.
workdir:
- ''
- 'test/e2e'
- 'test/e2e/app'
- 'test/loadtime'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
Expand All @@ -28,11 +36,12 @@ jobs:
with:
PATTERNS: |
**/**.go
go.mod
go.sum
**/go.mod
**/go.sum
- uses: golangci/golangci-lint-action@v3
with:
version: latest
args: --timeout 10m
github-token: ${{ secrets.github_token }}
working-directory: ${{ matrix.workdir }}
if: env.GIT_DIFF
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,5 @@ proto/spec/**/*.pb.go
*.dvi
# Python virtual environments
.venv
go.work
go.work.sum
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,9 @@ format:
lint:
@echo "--> Running linter"
@go run github.com/golangci/golangci-lint/cmd/golangci-lint@latest run
@$(MAKE) -C ./test/e2e/ lint
@$(MAKE) -C ./test/e2e/app/ lint
@$(MAKE) -C ./test/loadtime/ lint
.PHONY: lint

vulncheck:
Expand Down
4 changes: 2 additions & 2 deletions abci/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"sync"

"github.com/cometbft/cometbft/abci/types"
"github.com/cometbft/cometbft/libs/service"
cmtsync "github.com/cometbft/cometbft/libs/sync"
"github.com/cometbft/cometbft/internal/service"
cmtsync "github.com/cometbft/cometbft/internal/sync"
)

const (
Expand Down
4 changes: 2 additions & 2 deletions abci/client/grpc_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"google.golang.org/grpc/credentials/insecure"

"github.com/cometbft/cometbft/abci/types"
cmtnet "github.com/cometbft/cometbft/libs/net"
"github.com/cometbft/cometbft/libs/service"
cmtnet "github.com/cometbft/cometbft/internal/net"
"github.com/cometbft/cometbft/internal/service"
)

var _ Client = (*grpcClient)(nil)
Expand Down
5 changes: 3 additions & 2 deletions abci/client/grpc_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ import (

"golang.org/x/net/context"

"github.com/cometbft/cometbft/libs/log"
cmtnet "github.com/cometbft/cometbft/libs/net"
"google.golang.org/grpc/credentials/insecure"

cmtnet "github.com/cometbft/cometbft/internal/net"
"github.com/cometbft/cometbft/libs/log"

abciserver "github.com/cometbft/cometbft/abci/server"
"github.com/cometbft/cometbft/abci/types"
)
Expand Down
4 changes: 2 additions & 2 deletions abci/client/local_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"context"

types "github.com/cometbft/cometbft/abci/types"
"github.com/cometbft/cometbft/libs/service"
cmtsync "github.com/cometbft/cometbft/libs/sync"
"github.com/cometbft/cometbft/internal/service"
cmtsync "github.com/cometbft/cometbft/internal/sync"
)

// NOTE: use defer to unlock mutex because Application might panic (e.g., in
Expand Down
6 changes: 3 additions & 3 deletions abci/client/socket_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (
"time"

"github.com/cometbft/cometbft/abci/types"
cmtnet "github.com/cometbft/cometbft/libs/net"
"github.com/cometbft/cometbft/libs/service"
"github.com/cometbft/cometbft/libs/timer"
cmtnet "github.com/cometbft/cometbft/internal/net"
"github.com/cometbft/cometbft/internal/service"
"github.com/cometbft/cometbft/internal/timer"
)

const (
Expand Down
4 changes: 2 additions & 2 deletions abci/client/socket_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import (
abcicli "github.com/cometbft/cometbft/abci/client"
"github.com/cometbft/cometbft/abci/server"
"github.com/cometbft/cometbft/abci/types"
cmtrand "github.com/cometbft/cometbft/libs/rand"
"github.com/cometbft/cometbft/libs/service"
cmtrand "github.com/cometbft/cometbft/internal/rand"
"github.com/cometbft/cometbft/internal/service"
)

func TestCalls(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion abci/client/unsync_local_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"sync"

types "github.com/cometbft/cometbft/abci/types"
"github.com/cometbft/cometbft/libs/service"
"github.com/cometbft/cometbft/internal/service"
)

type unsyncLocalClient struct {
Expand Down
629A
2 changes: 1 addition & 1 deletion abci/cmd/abci-cli/abci-cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (

"github.com/spf13/cobra"

cmtos "github.com/cometbft/cometbft/internal/os"
"github.com/cometbft/cometbft/libs/log"
cmtos "github.com/cometbft/cometbft/libs/os"

abcicli "github.com/cometbft/cometbft/abci/client"
"github.com/cometbft/cometbft/abci/example/kvstore"
Expand Down
2 changes: 1 addition & 1 deletion abci/example/kvstore/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/cometbft/cometbft/abci/types"
cryptoencoding "github.com/cometbft/cometbft/crypto/encoding"
cmtrand "github.com/cometbft/cometbft/libs/rand"
cmtrand "github.com/cometbft/cometbft/internal/rand"
"github.com/cometbft/cometbft/proto/tendermint/crypto"
)

Expand Down
2 changes: 1 addition & 1 deletion abci/example/kvstore/kvstore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (

"github.com/stretchr/testify/require"

"github.com/cometbft/cometbft/internal/service"
"github.com/cometbft/cometbft/libs/log"
"github.com/cometbft/cometbft/libs/service"

abcicli "github.com/cometbft/cometbft/abci/client"
abciserver "github.com/cometbft/cometbft/abci/server"
Expand Down
4 changes: 2 additions & 2 deletions abci/server/grpc_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"google.golang.org/grpc"

"github.com/cometbft/cometbft/abci/types"
cmtnet "github.com/cometbft/cometbft/libs/net"
"github.com/cometbft/cometbft/libs/service"
cmtnet "github.com/cometbft/cometbft/internal/net"
"github.com/cometbft/cometbft/internal/service"
)

type GRPCServer struct {
Expand Down
2 changes: 1 addition & 1 deletion abci/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ package server

import (
"github.com/cometbft/cometbft/abci/types"
"github.com/cometbft/cometbft/libs/service"
"github.com/cometbft/cometbft/internal/service"
)

// NewServer is a utility function for out of process applications to set up either a socket or
Expand Down
14 changes: 7 additions & 7 deletions abci/server/socket_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import (
"runtime"

"github.com/cometbft/cometbft/abci/types"
cmtnet "github.com/cometbft/cometbft/internal/net"
"github.com/cometbft/cometbft/internal/service"
cmtsync "github.com/cometbft/cometbft/internal/sync"
cmtlog "github.com/cometbft/cometbft/libs/log"
cmtnet "github.com/cometbft/cometbft/libs/net"
"github.com/cometbft/cometbft/libs/service"
cmtsync "github.com/cometbft/cometbft/libs/sync"
)

// SocketServer is the server-side implementation of the TSP (Tendermint Socket Protocol)
Expand Down Expand Up @@ -162,7 +162,7 @@ func (s *SocketServer) waitForClose(closeConn chan error, connID int) {
// Read requests from conn and deal with them
func (s *SocketServer) handleRequests(closeConn chan error, conn io.Reader, responses chan<- *types.Response) {
var count int
var bufReader = bufio.NewReader(conn)
bufReader := bufio.NewReader(conn)

defer func() {
// make sure to recover from any app-related panics to allow proper socket cleanup.
Expand All @@ -184,7 +184,7 @@ func (s *SocketServer) handleRequests(closeConn chan error, conn io.Reader, resp

for {

var req = &types.Request{}
req := &types.Request{}
err := types.ReadMessage(bufReader, req)
if err != nil {
if err == io.EOF {
Expand Down Expand Up @@ -308,9 +308,9 @@ func (s *SocketServer) handleRequest(ctx context.Context, req *types.Request) (*
// Pull responses from 'responses' and write them to conn.
func (s *SocketServer) handleResponses(closeConn chan error, conn io.Writer, responses <-chan *types.Response) {
var count int
var bufWriter = bufio.NewWriter(conn)
bufWriter := bufio.NewWriter(conn)
for {
var res = <-responses
res := <-responses
err := types.WriteMessage(res, bufWriter)
if err != nil {
closeConn <- fmt.Errorf("error writing message: %w", err)
Expand Down
9 changes: 4 additions & 5 deletions abci/tests/benchmarks/parallel/parallel.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ import (
"log"

"github.com/cometbft/cometbft/abci/types"
cmtnet "github.com/cometbft/cometbft/libs/net"
cmtnet "github.com/cometbft/cometbft/internal/net"
)

func main() {

conn, err := cmtnet.Connect("unix://test.sock")
if err != nil {
log.Fatal(err.Error())
Expand All @@ -20,7 +19,7 @@ func main() {
go func() {
counter := 0
for {
var res = &types.Response{}
res := &types.Response{}
err := types.ReadMessage(conn, res)
if err != nil {
log.Fatal(err.Error())
Expand All @@ -35,8 +34,8 @@ func main() {
// Write a bunch of requests
counter := 0
for i := 0; ; i++ {
var bufWriter = bufio.NewWriter(conn)
var req = types.ToRequestEcho("foobar")
bufWriter := bufio.NewWriter(conn)
req := types.ToRequestEcho("foobar")

err := types.WriteMessage(req, bufWriter)
if err != nil {
Expand Down
9 changes: 4 additions & 5 deletions abci/tests/benchmarks/simple/simple.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ import (
"reflect"

"github.com/cometbft/cometbft/abci/types"
cmtnet "github.com/cometbft/cometbft/libs/net"
cmtnet "github.com/cometbft/cometbft/internal/net"
)

func main() {

conn, err := cmtnet.Connect("unix://test.sock")
if err != nil {
log.Fatal(err.Error())
Expand All @@ -34,7 +33,7 @@ func main() {
}

func makeRequest(conn io.ReadWriter, req *types.Request) (*types.Response, error) {
var bufWriter = bufio.NewWriter(conn)
bufWriter := bufio.NewWriter(conn)

// Write desired request
err := types.WriteMessage(req, bufWriter)
Expand All @@ -51,12 +50,12 @@ func makeRequest(conn io.ReadWriter, req *types.Request) (*types.Response, error
}

// Read desired response
var res = &types.Response{}
res := &types.Response{}
err = types.ReadMessage(conn, res)
if err != nil {
return nil, err
}
var resFlush = &types.Response{}
resFlush := &types.Response{}
err = types.ReadMessage(conn, resFlush)
if err != nil {
return nil, err
Expand Down
Loading
0