Skip to content
Open
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
5 changes: 2 additions & 3 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"fmt"
"io"
"io/fs"
"maps"
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Confirm toolchain supports stdlib “maps” (Go 1.21+).

The new import relies on the standard library package maps, which requires Go 1.21+. It looks consistent with existing usage of slices (also Go 1.21+), but please confirm CI/tooling is pinned accordingly to avoid build breaks.

Run this script to verify the repo’s Go version and CI setup:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "go.mod go/toolchain directives:"
rg -nP '^(go|toolchain)\s+\d' go.mod || true
sed -n '1,20p' go.mod | nl -ba

echo -e "\nCheck workflows pinning setup-go:"
fd -t f -a .github/workflows -e yml -e yaml | while read -r f; do
  echo "==> $f"
  rg -nP 'setup-go|go-version' "$f" || true
done

echo -e "\nSearch for local helpers named max/min that might mask missing stdlib cmp.Max/Min:"
rg -nP -C2 '(?m)^\s*func\s+(max|min)\s*\[.*\]\s*\(.*\)|^\s*func\s+(max|min)\s*\('

Length of output: 268


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Checking go.mod for go/toolchain directives:"
grep -nE '^\s*(go|toolchain)\s+' go.mod || echo "No go/toolchain directives found"

echo -e "\nInspecting top of go.mod (first 20 lines):"
head -n 20 go.mod

echo -e "\nScanning GitHub Actions workflows for Go version pins:"
find .github/workflows -type f \( -name '*.yml' -o -name '*.yaml' \) | while read -r wf; do
  echo "==> $wf"
  grep -nE 'setup-go|go-version' "$wf" || echo "  (no Go version pin found)"
done

echo -e "\nSearching for local max/min functions:"
rg -nP -C2 '(?m)^\s*func\s+(max|min)\s*\[' --color=always || echo "No generic max/min helpers detected"

Length of output: 5528


Ensure all CI workflows pin Go ≥1.21 (maps package available in Go 1.21+)

go.mod already specifies go 1.23.12, so the new maps import is supported by your toolchain. A search also found no local max/min helpers that could shadow stdlib functions.

However, CI is currently inconsistent:

  • Some workflows pin to older Go (1.22.x)
    .github/workflows/lint.yml uses go-version: '1.22.7'
    .github/workflows/sims.yml uses go-version: '^1.22.0'
  • Several workflows don’t install Go explicitly, relying on the runner’s default (which may be < 1.23)
    build.yml, container.yml, gosec.yml, lint-pr.yml, pr_labeler.yml, proto.yml, release.yml, semgrep.yml, test.yml

Please update each workflow that builds, tests, or lints Go code to include an explicit setup, for example:

- uses: actions/setup-go@v5
  with:
    go-version: '1.23.12'

Or use a semver range:

    go-version: '^1.23.0'

so that your CI always runs on a Go version compatible with the maps package.

🤖 Prompt for AI Agents
In app/app.go around line 11 the new "maps" import requires Go ≥1.21, but CI
uses older or unspecified Go versions; update all GitHub workflow files that
build/test/lint Go (at least .github/workflows/lint.yml, sims.yml, build.yml,
container.yml, gosec.yml, lint-pr.yml, pr_labeler.yml, proto.yml, release.yml,
semgrep.yml, test.yml) to explicitly install a compatible Go version (e.g., add
an actions/setup-go@v5 step with go-version: '1.23.12' or a semver range like
'^1.23.0') so the CI runners always use Go >=1.21 (prefer matching go.mod, e.g.,
1.23.12).

"math"
"net/http"
"os"
Expand Down Expand Up @@ -1343,9 +1344,7 @@ func RegisterSwaggerAPI(_ client.Context, rtr *mux.Router) {
// GetMaccPerms returns a copy of the module account permissions
func GetMaccPerms() map[string][]string {
dupMaccPerms := make(map[string][]string)
for k, v := range maccPerms {
dupMaccPerms[k] = v
}
maps.Copy(dupMaccPerms, maccPerms)
return dupMaccPerms
}

Expand Down
6 changes: 2 additions & 4 deletions x/cronos/rpc/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,9 @@ func (api *CronosAPI) ReplayBlock(blockNrOrHash rpctypes.BlockNumberOrHash, post
}

// minus one to get the context of block beginning
contextHeight := blockNumber - 1
if contextHeight < 1 {
contextHeight := max(blockNumber-1,
// 0 is a special value in `ContextWithHeight`
contextHeight = 1
}
1)
rsp, err := api.cronosQueryClient.ReplayBlock(rpctypes.ContextWithHeight(contextHeight), req)
if err != nil {
return nil, err
Expand Down