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

Bump go to v1.23 (from v1.21) #2132

Merged
merged 18 commits into from
Aug 22, 2024
Merged

Bump go to v1.23 (from v1.21) #2132

merged 18 commits into from
Aug 22, 2024

Conversation

SpicyLemon
Copy link
Contributor

@SpicyLemon SpicyLemon commented Aug 21, 2024

Description

This PR:

  • Bumps the version of go needed/used to v1.23 (from v1.21).
  • Bumps the version of golangci-lint needed/used to v1.60.2 (from v1.54.2).
  • Fixes all the new lint errors that cropped up.
  • Removes internal/collections/maps.go since it's only function (Keys) is now part of the maps built-in library.

You can update your local golangci-lint using make golangci-lint-update, or install it using make golangci-lint. Those targets aren't new, but have been updated to use the new version.

As of Wed, Aug 21, the heighliner job (in the Docker Build and Push workflow) is failing because it doesn't yet support go v1.23. Once they do, that job should fix itself. I created issue #270 with them to add support for go v1.23.


Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against correct branch (see CONTRIBUTING.md).
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Wrote unit and integration tests
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/).
  • Added relevant godoc comments.
  • Added relevant changelog entries under .changelog/unreleased (see Adding Changes).
  • Re-reviewed Files changed in the Github PR explorer.
  • Review Codecov Report in the comment section below once CI passes.

Summary by CodeRabbit

  • New Features

    • Updated the project to require Go version 1.23 and enhanced development workflows.
    • Introduced a new function for generating testing accounts with specified bond tokens.
  • Bug Fixes

    • Enhanced error handling and message clarity in several functions across the codebase.
  • Documentation

    • Updated README and build documentation to specify the new minimum Go version requirement.
  • Refactor

    • Improved code readability and maintainability by renaming variables and extracting logic into functions.
  • Style

    • Standardized comments and formatting for clarity and to suppress linting warnings.
  • Chores

    • Upgraded dependencies such as GolangCI Lint to version 1.60.2.

Copy link
Contributor

coderabbitai bot commented Aug 21, 2024

Walkthrough

The recent updates enhance the project by upgrading the Go language from version 1.21 to 1.23, which introduces new features and improvements. This change also includes updates to various GitHub Actions workflows for better Go version handling, improvements to linting configurations, and enhancements in documentation clarity. Additionally, several code adjustments improve readability, maintainability, and type safety across the application.

Changes

Files Change Summary
.changelog/unreleased/dependencies/..., README.md, docs/Building.md, go.mod Updated Go version from 1.21 to 1.23, enhancing compatibility and clarifying documentation on version requirements.
.github/workflows/*.yml Altered GitHub Actions workflows to dynamically reference the Go version from go.mod instead of hardcoding, improving maintainability and consistency.
.golangci.yml Added copyloopvar linter, removed exportloopref, and refined errcheck configuration for better error handling practices.
Makefile Updated supported Go version and enhanced installation process by validating the Go version before installation.
app/prefix.go, app/prefix_test/prefix_test.go Changed coin type constants to uint32 for better type safety and updated corresponding test expectations.
cmd/provenanced/cmd/tree.go Refined output formatting in command outputs for better clarity.
contrib/devtools/Makefile, docker/...Dockerfile Updated GOLANGCI_LINT_VERSION and base image to newer versions for improved linting capabilities and build environment.
internal/..., x/... Multiple code adjustments for improved readability, consistency in type handling, and refined error messages across various functions and tests.

Sequence Diagram(s)

sequenceDiagram
    participant Developer
    participant GitHubActions
    participant GoModule
    participant Linter

    Developer->>GoModule: Update code and dependencies
    Developer->>GitHubActions: Modify workflows for dynamic Go versioning
    GitHubActions->>GoModule: Reference Go version from go.mod
    GitHubActions->>Linter: Run lint checks with updated configurations
    Linter-->>Developer: Provide feedback on code quality
Loading

🐰 "Hopping through code, what a delight,
With new Go updates, everything's bright!
Linting and workflows, all in a row,
Clearer and cleaner, watch our project grow!
From constants to tests, each change is a cheer,
Let's celebrate progress, for spring is near!" 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

…irect uses of the 'go' command with the $(GO) variable.
…eed it are doing it on their own still anyway.
…mp (since it's a pretty important change to note).
…'s currently using v1.22 which causes make install to fail.
…eded golang version since the dockerfile might pick up on it.
…t the problem. Digging into their stuff, they don't yet have support for go v1.23, so we'll just have to wait.
@SpicyLemon SpicyLemon marked this pull request as ready for review August 21, 2024 23:42
@SpicyLemon SpicyLemon requested a review from a team as a code owner August 21, 2024 23:42
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between d4c3b76 and 9e89ad2.

Files selected for processing (55)
  • .changelog/unreleased/dependencies/2132-bump-go-to-1.23.md (1 hunks)
  • .changelog/unreleased/summary.md (1 hunks)
  • .github/workflows/docker.yml (1 hunks)
  • .github/workflows/lint.yml (1 hunks)
  • .github/workflows/proto.yml (1 hunks)
  • .github/workflows/release.yml (4 hunks)
  • .github/workflows/sims.yml (9 hunks)
  • .github/workflows/test.yml (3 hunks)
  • .golangci.yml (2 hunks)
  • Makefile (5 hunks)
  • README.md (1 hunks)
  • app/prefix.go (2 hunks)
  • app/prefix_test/prefix_test.go (2 hunks)
  • cmd/provenanced/cmd/tree.go (1 hunks)
  • contrib/devtools/Makefile (1 hunks)
  • docker/blockchain/Dockerfile (1 hunks)
  • docs/Building.md (1 hunks)
  • go.mod (1 hunks)
  • internal/antewrapper/min_gas_prices_decorator.go (1 hunks)
  • internal/rand/int.go (1 hunks)
  • internal/rand/int_test.go (2 hunks)
  • networks/dev/blockchain-dev/Dockerfile (2 hunks)
  • networks/ibc/blockchain-ibc/Dockerfile (2 hunks)
  • networks/ibc/blockchain-relayer/Dockerfile (1 hunks)
  • networks/local/blockchain-local/Dockerfile (2 hunks)
  • testutil/sims.go (3 hunks)
  • x/attribute/client/cli/tx.go (1 hunks)
  • x/attribute/keeper/query_server.go (4 hunks)
  • x/attribute/simulation/operations.go (3 hunks)
  • x/exchange/client/cli/flags.go (2 hunks)
  • x/exchange/client/cli/tx_test.go (4 hunks)
  • x/exchange/keeper/msg_server.go (1 hunks)
  • x/exchange/keeper/params.go (2 hunks)
  • x/exchange/market_test.go (4 hunks)
  • x/hold/keeper/keeper_test.go (3 hunks)
  • x/marker/client/cli/tx.go (1 hunks)
  • x/marker/keeper/msg_server.go (3 hunks)
  • x/marker/keeper/params.go (1 hunks)
  • x/marker/keeper/query_server.go (2 hunks)
  • x/marker/simulation/genesis.go (1 hunks)
  • x/marker/simulation/operations.go (6 hunks)
  • x/marker/types/msgs.go (1 hunks)
  • x/marker/types/si.go (1 hunks)
  • x/metadata/keeper/msg_server.go (2 hunks)
  • x/metadata/keeper/oslocatorparams.go (1 hunks)
  • x/metadata/keeper/query_server.go (1 hunks)
  • x/metadata/types/scope.go (2 hunks)
  • x/msgfees/keeper/keeper.go (3 hunks)
  • x/msgfees/types/msgs.go (1 hunks)
  • x/name/client/cli/tx.go (1 hunks)
  • x/name/keeper/keeper.go (1 hunks)
  • x/name/simulation/genesis.go (1 hunks)
  • x/oracle/simulation/genesis.go (1 hunks)
  • x/trigger/keeper/event_detector.go (1 hunks)
  • x/trigger/simulation/genesis.go (4 hunks)
Files skipped from review due to trivial changes (24)
  • .changelog/unreleased/dependencies/2132-bump-go-to-1.23.md
  • .github/workflows/docker.yml
  • .github/workflows/proto.yml
  • README.md
  • cmd/provenanced/cmd/tree.go
  • docs/Building.md
  • internal/rand/int.go
  • internal/rand/int_test.go
  • networks/local/blockchain-local/Dockerfile
  • x/attribute/keeper/query_server.go
  • x/attribute/simulation/operations.go
  • x/exchange/client/cli/flags.go
  • x/exchange/keeper/params.go
  • x/marker/client/cli/tx.go
  • x/marker/keeper/params.go
  • x/marker/simulation/genesis.go
  • x/marker/types/si.go
  • x/metadata/keeper/oslocatorparams.go
  • x/metadata/keeper/query_server.go
  • x/metadata/types/scope.go
  • x/msgfees/types/msgs.go
  • x/name/client/cli/tx.go
  • x/name/simulation/genesis.go
  • x/oracle/simulation/genesis.go
Additional context used
GitHub Check: docker
docker/blockchain/Dockerfile

[warning] 1-1: The 'as' keyword should match the case of the 'from' keyword
FromAsCasing: 'as' and 'FROM' keywords' casing do not match
More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/

Additional comments not posted (48)
.changelog/unreleased/summary.md (1)

1-2: Documentation updates are clear and concise.

The changelog summary effectively communicates the new requirements for building and linting.

networks/ibc/blockchain-relayer/Dockerfile (1)

2-2: Base image update aligns with PR objectives.

The Dockerfile now uses Go 1.23, which is consistent with the project's updated requirements.

.github/workflows/lint.yml (2)

33-33: Dynamic Go version management improves adaptability.

The workflow now references go.mod for the Go version, enhancing flexibility.


38-38: Updated GolangCI Lint action version.

The workflow uses golangci-lint version 1.60, ensuring the latest linting capabilities.

app/prefix.go (1)

10-11: Explicit typing of constants enhances type safety.

The explicit declaration of CoinTypeMainNet and CoinTypeTestNet as uint32 improves type safety and clarity. The updates in the SetConfig function are consistent with these changes.

Also applies to: 42-42

networks/ibc/blockchain-ibc/Dockerfile (1)

6-6: Go version update in Dockerfile approved.

The update to golang:1.23-bullseye for both x86_64 and ARM architectures is consistent with the PR's objective and is correctly implemented.

Also applies to: 55-55

networks/dev/blockchain-dev/Dockerfile (1)

5-5: Verify compatibility with Go 1.23.

The Dockerfile has been updated to use Go 1.23. Ensure that all dependencies and code are compatible with this version to avoid runtime issues.

Run the following script to search for any Go version-specific dependencies or code that might need attention:

Also applies to: 51-51

internal/antewrapper/min_gas_prices_decorator.go (1)

64-64: Improved precision in gas limit conversion.

The change to use LegacyNewDecFromBigInt enhances precision when converting the gas limit to a decimal representation. This is a beneficial update.

contrib/devtools/Makefile (1)

83-83: Updated GolangCI Lint to v1.60.2.

The update to GolangCI Lint version v1.60.2 ensures that the latest linting features and fixes are applied. This is a positive change.

x/trigger/keeper/event_detector.go (1)

56-57: Improved type consistency in block height comparisons.

The use of uint64 for curHeight ensures type consistency in block height comparisons, reducing the risk of type-related issues.

Also applies to: 61-62

.golangci.yml (1)

12-12: Updated linter configuration for improved code quality.

The addition of copyloopvar and removal of exportloopref reflect a refined linting strategy. The exclusion of (fmt.State).Write from errcheck suggests specific error handling for this function.

Also applies to: 153-155

app/prefix_test/prefix_test.go (1)

40-40: Enhanced type safety and test clarity.

Changing expCoinType to uint32 ensures type alignment with the application logic. The improved error messages provide clearer test failure information.

Also applies to: 154-155

x/marker/keeper/query_server.go (2)

41-41: Simplified error handling in AllMarkers.

The change from status.Errorf to status.Error simplifies error creation but removes formatting capabilities. Ensure that the error message clarity is not compromised.


65-65: Simplified error handling in Marker.

The change from status.Errorf to status.Error simplifies error creation but removes formatting capabilities. Ensure that the error message clarity is not compromised.

.github/workflows/sims.yml (4)

66-66: Use go-version-file for dynamic version management.

The change to use go-version-file: 'go.mod' allows the workflow to derive the Go version directly from the module file. This simplifies version management.


95-95: Use go-version-file for dynamic version management.

The change to use go-version-file: 'go.mod' allows the workflow to derive the Go version directly from the module file. This simplifies version management.


147-147: Use go-version-file for dynamic version management.

The change to use go-version-file: 'go.mod' allows the workflow to derive the Go version directly from the module file. This simplifies version management.


184-184: Use go-version-file for dynamic version management.

The change to use go-version-file: 'go.mod' allows the workflow to derive the Go version directly from the module file. This simplifies version management.

x/trigger/simulation/genesis.go (3)

139-141: Improved parameter naming in randomTriggerAndQueueIDs.

The parameter max has been renamed to maxCount, enhancing code readability by clearly indicating its purpose.


145-149: Improved parameter naming and logic in randomTriggerIDs.

The parameter max has been renamed to maxCount, and the logic now uses maxCount for clarity. The panic message has been updated to reflect this change.


206-208: Added validation for triggerID in RandomizedGenState.

A new check ensures that triggerID does not exceed math.MaxInt, preventing potential runtime errors. This enhances the robustness of the code.

.github/workflows/test.yml (1)

106-106: Approved: Use go.mod for Go version management.

Switching to go-version-file: 'go.mod' ensures that the workflow always uses the correct Go version specified by the project, enhancing consistency and maintainability.

Also applies to: 193-193

.github/workflows/release.yml (1)

70-70: Approved: Use go.mod for Go version management.

Switching to go-version-file: 'go.mod' ensures that the workflow always uses the correct Go version specified by the project, enhancing consistency and maintainability.

Also applies to: 95-95, 165-165

x/msgfees/keeper/keeper.go (3)

11-11: Approved: Import sdkmath for improved precision.

The addition of sdkmath enhances the precision of mathematical operations, which is beneficial for handling coin amounts accurately.


185-187: Approved: Use sdkmath for nhashPerMil calculation.

The change to use sdkmath.NewIntFromUint64 and Mul improves the precision and robustness of the ConvertDenomToHash function.


313-316: Approved: Simplify DetermineBips logic.

The refined logic in DetermineBips enhances readability by directly checking bips64 against the upper limit before assigning bips.

go.mod (1)

3-3: Go version update approved.

The Go version has been successfully updated to 1.23. Ensure compatibility with all dependencies.

x/attribute/client/cli/tx.go (1)

342-343: Type conversion refactor approved.

The explicit type conversion to uint32 improves readability and clarity.

x/name/keeper/keeper.go (1)

266-271: Type change for segment length approved.

Changing segLen to int ensures proper type alignment for comparisons. Verify the impact on related logic, especially where negative values or larger integers might be involved.

Run the following script to verify the impact on related logic:

Verification successful

Type change for segLen verified. The change to int aligns with the logic in keeper.go and ensures consistent type alignment for comparisons. No issues found with this change.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the impact of changing segLen to int in related logic.

# Test: Search for usage of Normalize function. Expect: No issues with type alignment.
rg --type go -A 5 $'Normalize'

Length of output: 52377


Script:

#!/bin/bash
# Search for usage of segLen and related logic in keeper.go to verify the impact of changing segLen to int.
rg --type go 'segLen' -A 5 -B 5

Length of output: 899

testutil/sims.go (2)

Line range hint 11-20: LGTM! Enhanced logging flexibility.

The addition of a format specifier in LogOperationMsg improves logging flexibility.


41-43: Verify usage of GenerateTestingAccounts.

The new function GenerateTestingAccounts is correctly implemented. Ensure that it is used appropriately in the codebase.

Run the following script to verify the function usage:

Verification successful

Function GenerateTestingAccounts is correctly integrated and used.

The function GenerateTestingAccounts is appropriately used across multiple test files, confirming its integration into the testing framework.

  • Files using GenerateTestingAccounts:
    • x/trigger/simulation/operations_test.go
    • x/oracle/simulation/operations_test.go
    • x/marker/simulation/operations_test.go
    • testutil/sims.go
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify usage of `GenerateTestingAccounts`.

# Test: Search for the function usage. Expect: Occurrences of the new function.
rg --type go -A 5 $'GenerateTestingAccounts'

Length of output: 4527

x/exchange/keeper/msg_server.go (1)

331-333: LGTM! Simplified error handling.

The change from Wrapf to Wrap simplifies error handling without affecting functionality.

Makefile (3)

37-39: LGTM! Updated Go version to 1.23.

The supported Go version is correctly updated to 1.23.


131-131: LGTM! Enhanced installation process.

The addition of Go version validation to the install target improves robustness.


Line range hint 485-495: LGTM! Improved command consistency.

The use of the $(GO) variable enhances consistency in Go module management commands.

x/marker/types/msgs.go (1)

427-429: Simplification of AccessList validation is appropriate.

The removal of the nil check for AccessList is a good simplification, assuming that AccessList is always initialized. This enhances code readability without compromising correctness.

x/marker/simulation/operations.go (5)

112-115: Introduction of randMarkerType improves readability.

The use of a dedicated function randMarkerType to determine the marker type enhances code readability and maintainability. This encapsulation is a good practice.


202-202: Use of randMarkerType in SimulateMsgAddFinalizeActivateMarker.

The refactoring to use randMarkerType here improves consistency and readability across the codebase.


236-237: Clarification of variable names enhances understanding.

Renaming variables like max to maxLen and min to minLen in randomUnrestrictedDenom function improves clarity and aligns the names with their purpose.


533-538: Renaming parameter in randomInt63 improves clarity.

Changing the parameter name from max to maxVal clarifies its intent, enhancing code readability.


540-541: Addition of randMarkerType function is well-implemented.

The new function randMarkerType encapsulates the logic for determining marker types, improving code organization and readability.

x/marker/keeper/msg_server.go (2)

117-118: Improved precision in AddMarker with sdkmath.NewIntFromUint64.

The change to use sdkmath.NewIntFromUint64 for UsdMills enhances precision and correctness in handling monetary values. This is a positive update for financial calculations.


520-521: Enhanced precision in AddFinalizeActivateMarker.

Using sdkmath.NewIntFromUint64 for UsdMills ensures better precision in financial calculations, which is a crucial improvement.

x/metadata/keeper/msg_server.go (1)

49-50: LGTM! Improved type safety for UsdMills.

The change to use sdkmath.NewIntFromUint64 and types.NewNetAssetValue enhances type safety and robustness in handling UsdMills.

x/hold/keeper/keeper_test.go (1)

5-6: LGTM! Use of standard library functions.

The transition to using maps.Keys and slices.Collect from the standard library enhances readability and maintainability.

x/exchange/client/cli/tx_test.go (1)

6-7: LGTM! Use of standard library functions.

The transition to using maps.Keys and slices.Collect from the standard library enhances readability and maintainability.

x/exchange/market_test.go (2)

3157-3157: Great use of Go's standard library!

The use of maps.Keys and slices.Collect enhances readability and performance by leveraging Go's built-in capabilities.


3334-3334: Consistent use of Go's standard library!

The use of maps.Keys and slices.Collect is consistent with best practices and improves code clarity.

docker/blockchain/Dockerfile Show resolved Hide resolved
Copy link
Member

@iramiller iramiller left a comment

Choose a reason for hiding this comment

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

lots of little clean up in here ... I like the removal of a bunch of fmt.Sprintf calls

@iramiller iramiller merged commit c702324 into main Aug 22, 2024
36 of 37 checks passed
@iramiller iramiller deleted the dwedul/bump-go-1.23 branch August 22, 2024 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants