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

drop golang 1.21 support #97

Merged
merged 10 commits into from
Oct 16, 2024
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions .github/workflows/go-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 ./...
5 changes: 2 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 (
Expand All @@ -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
Expand Down
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down
2 changes: 1 addition & 1 deletion internal/erigon_node/bodies_download.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
//}
}*/
Expand Down
2 changes: 1 addition & 1 deletion internal/erigon_node/headers_download.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
//}
}*/
14 changes: 7 additions & 7 deletions internal/erigon_node/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions internal/erigon_node/sync_stages.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions internal/sessions/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down