diff --git a/.github/workflows/go-checks.yml b/.github/workflows/go-checks.yml index 9c5397f..0be45a6 100644 --- a/.github/workflows/go-checks.yml +++ b/.github/workflows/go-checks.yml @@ -13,11 +13,10 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: '1.21' + go-version: '1.22' - run: go mod tidy - - uses: golangci/golangci-lint-action@v4 + - uses: golangci/golangci-lint-action@v6 with: - version: 'v1.57' - skip-pkg-cache: true + version: 'v1.61' - run: go build -v ./... - run: go test -v ./... diff --git a/go.mod b/go.mod index 0544f18..01879a1 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/erigontech/diagnostics -go 1.21 +go 1.22 require ( github.com/go-chi/chi/v5 v5.0.12 @@ -13,7 +13,7 @@ require ( require ( github.com/go-chi/cors v1.2.1 - github.com/gorilla/websocket v1.5.1 + github.com/gorilla/websocket v1.5.3 ) require ( @@ -33,7 +33,6 @@ require ( github.com/subosito/gotenv v1.6.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f // indirect - golang.org/x/net v0.24.0 // indirect golang.org/x/sys v0.19.0 // indirect golang.org/x/text v0.14.0 // indirect gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect diff --git a/go.sum b/go.sum index 97d9087..166d5ef 100644 --- a/go.sum +++ b/go.sum @@ -15,8 +15,8 @@ github.com/go-chi/cors v1.2.1 h1:xEC8UT3Rlp2QuWNEr4Fs/c2EAGVKBwy/1vHx3bppil4= github.com/go-chi/cors v1.2.1/go.mod h1:sSbTewc+6wYHBBCW7ytsFSn836hqM7JxpglAy2Vzc58= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY= -github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY= +github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg= +github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k= github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= @@ -75,8 +75,6 @@ go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f h1:99ci1mjWVBWwJiEKYY6jWa4d2nTQVIEhZIptnrVb1XY= golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f/go.mod h1:/lliqkxwWAhPjf5oSOIJup2XcqJaw8RGS6k3TGEc7GI= -golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= -golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= diff --git a/internal/erigon_node/bodies_download.go b/internal/erigon_node/bodies_download.go index 2bbb70b..d622fb2 100644 --- a/internal/erigon_node/bodies_download.go +++ b/internal/erigon_node/bodies_download.go @@ -139,7 +139,7 @@ func (c *NodeClient) BodiesDownload(ctx context.Context, w http.ResponseWriter) return item.Id < bd.BlockNum+VisLimit // We limit visualisation to VisLimit first blocks }) //if err := templ.ExecuteTemplate(w, "body_download.html", bd); err != nil { - // fmt.Fprintf(w, "Executing body_download template: %v", err) + // fmt.Fprintf(w, "Executing body_download template: %w", err) // return //} }*/ diff --git a/internal/erigon_node/headers_download.go b/internal/erigon_node/headers_download.go index 422cf92..0977ef3 100644 --- a/internal/erigon_node/headers_download.go +++ b/internal/erigon_node/headers_download.go @@ -138,7 +138,7 @@ func (c *NodeClient) HeadersDownload(ctx context.Context, w http.ResponseWriter) return item.Id < hd.HeaderNum+VisLimit // We limit visualisation to VisLimit first blocks }) //if err := templ.ExecuteTemplate(w, "headers_download.html", hd); err != nil { - // fmt.Fprintf(w, "Executing headers_download template: %v", err) + // fmt.Fprintf(w, "Executing headers_download template: %w", err) // return //} }*/ diff --git a/internal/erigon_node/profile.go b/internal/erigon_node/profile.go index 0e1a379..ae19a9c 100644 --- a/internal/erigon_node/profile.go +++ b/internal/erigon_node/profile.go @@ -16,25 +16,25 @@ func (c *NodeClient) FindProfile(ctx context.Context, profile string) ([]byte, e request, err := c.fetch(ctx, profile, nil) if err != nil { - return nil, fmt.Errorf("Error fetching profile: %v", err) + return nil, fmt.Errorf("fetching profile: %w", err) } _, result, err := request.nextResult(ctx) if err != nil { - return nil, fmt.Errorf("Error fetching profile content: %v", err) + return nil, fmt.Errorf("fetching profile content: %w", err) } var content ProfileContent if err := json.Unmarshal(result, &content); err != nil { - return nil, fmt.Errorf("Error unmarshalling profile content: %v", err) + return nil, fmt.Errorf("unmarshalling profile content: %w", err) } //result is a file content so I need to save it to file and return the file path tempFile, err := os.CreateTemp("", "profile-*.pprof") if err != nil { - return nil, fmt.Errorf("Error creating temporary file: %v", err) + return nil, fmt.Errorf("creating temporary file: %w", err) } defer func() { @@ -49,13 +49,13 @@ func (c *NodeClient) FindProfile(ctx context.Context, profile string) ([]byte, e }() if _, err := tempFile.Write(content.Chunk); err != nil { - return nil, fmt.Errorf("Error writing to temporary file: %v", err) + return nil, fmt.Errorf("writing to temporary file: %w", err) } - cmd := exec.Command("go", "tool", "pprof", "-dot", tempFile.Name()) + cmd := exec.Command("go", "tool", "pprof", "-dot", tempFile.Name()) //nolint:gosec //TODO: i don't know how to fix gosec warning svgOutput, err := cmd.Output() if err != nil { - return nil, fmt.Errorf("Error generating SVG output: %v", err) + return nil, fmt.Errorf("generating SVG output: %w", err) } return svgOutput, nil diff --git a/internal/erigon_node/sync_stages.go b/internal/erigon_node/sync_stages.go index 304c5f4..e744d3e 100644 --- a/internal/erigon_node/sync_stages.go +++ b/internal/erigon_node/sync_stages.go @@ -28,7 +28,7 @@ func (c *NodeClient) FindSyncStages(ctx context.Context) (SyncStageProgress, err func (ss *SyncStages) fetchSyncStageProgress(ctx context.Context) (SyncStageProgress, error) { if cursorError := ss.rc.Init(ctx, syncStageDb, syncStageTable, nil); cursorError != nil { - return nil, fmt.Errorf("could not initialize remote cursor: %v", cursorError) + return nil, fmt.Errorf("could not initialize remote cursor: %w", cursorError) } syncStageProgress := make(SyncStageProgress) @@ -46,13 +46,13 @@ func (ss *SyncStages) fetchSyncStageProgress(ctx context.Context) (SyncStageProg syncProgress, unmarshalError := ss.unmarshal(v) if unmarshalError != nil { - return nil, fmt.Errorf("could not unmarshal sync stage data: %v", unmarshalError) + return nil, fmt.Errorf("could not unmarshal sync stage data: %w", unmarshalError) } syncStageProgress[syncStage] = strconv.FormatUint(syncProgress, syncProgressBase) } if e != nil { - return nil, fmt.Errorf("could not process remote cursor line: %v", e) + return nil, fmt.Errorf("could not process remote cursor line: %w", e) } return syncStageProgress, nil diff --git a/internal/sessions/helpers.go b/internal/sessions/helpers.go index 1e1bade..7f2e35b 100644 --- a/internal/sessions/helpers.go +++ b/internal/sessions/helpers.go @@ -9,8 +9,8 @@ func generatePIN() (uint64, error) { //if insecure { TODO fix this // return uint64(weakrand.Int63n(100_000_000)), nil //} - max := big.NewInt(100_000_000) // For an 8-digit PIN - randNum, err := rand.Int(rand.Reader, max) + _max := big.NewInt(100_000_000) // For an 8-digit PIN + randNum, err := rand.Int(rand.Reader, _max) if err != nil { return 0, err }