Skip to content
Draft

Updates #1056

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
9 changes: 7 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
- '**'

env:
GO_VERSION: "1.24.7"
GO_VERSION: "1.26.0"

jobs:
ci-lint:
Expand Down Expand Up @@ -250,6 +250,7 @@ jobs:
CURIO_HARMONYDB_HOSTS: ${{ steps.get-yb-ip.outputs.yb_ip }} # Use internal IP for DB host
LOTUS_HARMONYDB_HOSTS: ${{ steps.get-yb-ip.outputs.yb_ip }}
FFI_USE_OPENCL: 1
GOTOOLCHAIN: local
run: |
echo "Using YugabyteDB Container IP: ${{env.CURIO_HARMONYDB_HOSTS}}"
export CURIO_HARMONYDB_HOSTS=${{ env.CURIO_HARMONYDB_HOSTS }}
Expand Down Expand Up @@ -294,7 +295,7 @@ jobs:

- name: Install golangci-lint
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.6.2
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.10.1
shell: bash

- name: Lint
Expand Down Expand Up @@ -645,6 +646,10 @@ jobs:
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache: false

- name: Set GOTOOLCHAIN for coverage tools
run: echo "GOTOOLCHAIN=local" >> $GITHUB_ENV

- name: Download all coverage artifacts
uses: actions/download-artifact@v4
Expand Down
25 changes: 6 additions & 19 deletions alertmanager/alerts.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"fmt"
"math"
"slices"
"strings"
"time"

Expand Down Expand Up @@ -197,14 +198,7 @@ func taskFailureCheck(al *alerts) {
}

sealingTasks := []string{"SDR", "TreeD", "TreeRC", "PreCommitSubmit", "PoRep", "Finalize", "MoveStorage", "CommitSubmit", "WdPost", "ParkPiece"}
contains := func(s []string, e string) bool {
for _, a := range s {
if a == e {
return true
}
}
return false
}
contains := slices.Contains[[]string, string]

// Alerts for any sealing pipeline failures. Other tasks should have at least 5 failures for an alert
for name, count := range tmap {
Expand Down Expand Up @@ -337,10 +331,9 @@ func (al *alerts) getAddresses() ([]address.Address, []address.Address, error) {

// Get unique layers in use
for _, machine := range machineDetails {
machine := machine
// Split the Layers field into individual layers
layers := strings.Split(machine.Layers, ",")
for _, layer := range layers {
layers := strings.SplitSeq(machine.Layers, ",")
for layer := range layers {
layer = strings.TrimSpace(layer)
if _, exists := layerMap[layer]; !exists && layer != "" {
layerMap[layer] = true
Expand Down Expand Up @@ -445,10 +438,7 @@ func wdPostCheck(al *alerts) {
}

// Calculate from epoch for last AlertMangerInterval
from := head.Height() - abi.ChainEpoch(math.Ceil(AlertMangerInterval.Seconds()/float64(build.BlockDelaySecs))) - 1
if from < 0 {
from = 0
}
from := max(head.Height()-abi.ChainEpoch(math.Ceil(AlertMangerInterval.Seconds()/float64(build.BlockDelaySecs)))-1, 0)

_, miners, err := al.getAddresses()
if err != nil {
Expand Down Expand Up @@ -625,10 +615,7 @@ func wnPostCheck(al *alerts) {
}

// Calculate from epoch for last AlertMangerInterval
from := head.Height() - abi.ChainEpoch(math.Ceil(AlertMangerInterval.Seconds()/float64(build.BlockDelaySecs))) - 1
if from < 0 {
from = 0
}
from := max(head.Height()-abi.ChainEpoch(math.Ceil(AlertMangerInterval.Seconds()/float64(build.BlockDelaySecs)))-1, 0)

var wnDetails []struct {
Miner int64 `db:"sp_id"`
Expand Down
2 changes: 1 addition & 1 deletion alertmanager/curioalerting/al.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (as *AlertingSystem) AddAlertType(name, id string) alertinginterface.AlertT
}
}

func (as *AlertingSystem) Raise(alert alertinginterface.AlertType, metadata map[string]interface{}) {
func (as *AlertingSystem) Raise(alert alertinginterface.AlertType, metadata map[string]any) {
as.Lock()
defer as.Unlock()
as.Current[alert] = metadata
Expand Down
14 changes: 7 additions & 7 deletions alertmanager/plugin/pager_duty.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ func NewPagerDuty(cfg config.PagerDutyConfig) Plugin {
func (p *PagerDuty) SendAlert(data *AlertPayload) error {

type pdPayload struct {
Summary string `json:"summary"`
Severity string `json:"severity"`
Source string `json:"source"`
Component string `json:"component,omitempty"`
Group string `json:"group,omitempty"`
Class string `json:"class,omitempty"`
CustomDetails interface{} `json:"custom_details,omitempty"`
Summary string `json:"summary"`
Severity string `json:"severity"`
Source string `json:"source"`
Component string `json:"component,omitempty"`
Group string `json:"group,omitempty"`
Class string `json:"class,omitempty"`
CustomDetails any `json:"custom_details,omitempty"`
}

type pdData struct {
Expand Down
2 changes: 1 addition & 1 deletion alertmanager/plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type AlertPayload struct {
Summary string
Severity string
Source string
Details map[string]interface{}
Details map[string]any
Time time.Time
}

Expand Down
10 changes: 5 additions & 5 deletions alertmanager/plugin/prometheus_alertmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ func (p *PrometheusAlertManager) SendAlert(data *AlertPayload) error {
}

type amPayload struct {
StartsAt time.Time `json:"startsAt"`
EndsAt *time.Time `json:"EndsAt,omitempty"`
Annotations map[string]interface{} `json:"annotations"`
Labels map[string]string `json:"labels"`
StartsAt time.Time `json:"startsAt"`
EndsAt *time.Time `json:"EndsAt,omitempty"`
Annotations map[string]any `json:"annotations"`
Labels map[string]string `json:"labels"`

// is a unique back-link which identifies the causing entity of this alert
//GeneratorURL string `json:"generatorURL"`
Expand All @@ -49,7 +49,7 @@ func (p *PrometheusAlertManager) SendAlert(data *AlertPayload) error {
"severity": data.Severity,
"instance": data.Source,
},
Annotations: map[string]interface{}{
Annotations: map[string]any{
"summary": data.Summary,
"details": v,
},
Expand Down
2 changes: 1 addition & 1 deletion alertmanager/task_alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func (a *AlertTask) Do(taskID harmonytask.TaskID, stillOwned func() bool) (done
// Continue without muting on error
}

details := make(map[string]interface{})
details := make(map[string]any)
now := time.Now()

// Process regular alerts
Expand Down
6 changes: 3 additions & 3 deletions api/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ package api
import "reflect"

// GetInternalStructs extracts all pointers to 'Internal' sub-structs from the provided pointer to a proxy struct
func GetInternalStructs(in interface{}) []interface{} {
func GetInternalStructs(in any) []any {
return getInternalStructs(reflect.ValueOf(in).Elem())
}

var _internalField = "Internal"

func getInternalStructs(rv reflect.Value) []interface{} {
var out []interface{}
func getInternalStructs(rv reflect.Value) []any {
var out []any

internal := rv.FieldByName(_internalField)
ii := internal.Addr().Interface()
Expand Down
2 changes: 1 addition & 1 deletion api/docgen-openrpc/openrpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"reflect"

"github.com/alecthomas/jsonschema"
go_openrpc_reflect "github.com/etclabscore/go-openrpc-reflect"
go_openrpc_reflect "github.com/curiostorage/go-openrpc-reflect"
"github.com/ipfs/go-cid"
meta_schema "github.com/open-rpc/meta-schema"

Expand Down
40 changes: 29 additions & 11 deletions api/gen/api/proxygen.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ import (
"fmt"
"go/ast"
"go/format"
"go/parser"
"go/token"
"io"
"os"
"path/filepath"
"strings"
"text/template"

"golang.org/x/tools/go/packages"
"golang.org/x/xerrors"
)

Expand Down Expand Up @@ -117,7 +116,6 @@ func typeName(e ast.Expr, pkg string) (string, error) {
}

func generate(path, pkg, outpkg, outfile string) error {
fset := token.NewFileSet()
apiDir, err := filepath.Abs(path)
if err != nil {
return err
Expand All @@ -126,15 +124,34 @@ func generate(path, pkg, outpkg, outfile string) error {
if err != nil {
return err
}
pkgs, err := parser.ParseDir(fset, apiDir, nil, parser.AllErrors|parser.ParseComments)

cfg := &packages.Config{
Mode: packages.NeedName | packages.NeedFiles | packages.NeedSyntax | packages.NeedCompiledGoFiles,
Dir: apiDir,
}
loaded, err := packages.Load(cfg, ".")
if err != nil {
return err
}

ap := pkgs[pkg]
var ap *packages.Package
for _, p := range loaded {
if p.Name == pkg {
ap = p
break
}
}
if ap == nil {
return xerrors.Errorf("packages.Load: no package %q in %s", pkg, apiDir)
}
if len(ap.Errors) > 0 {
return ap.Errors[0]
}
fset := ap.Fset

v := &Visitor{make(map[string]map[string]*methodMeta), map[string][]string{}}
ast.Walk(v, ap)
for _, f := range ap.Syntax {
ast.Walk(v, f)
}

type methodInfo struct {
Num string
Expand All @@ -161,7 +178,8 @@ func generate(path, pkg, outpkg, outfile string) error {
Imports: map[string]string{},
}

for fn, f := range ap.Files {
for i, f := range ap.Syntax {
fn := ap.CompiledGoFiles[i]
if strings.HasSuffix(fn, "gen.go") {
continue
}
Expand Down Expand Up @@ -250,8 +268,8 @@ func generate(path, pkg, outpkg, outfile string) error {
if len(filteredComments) > 0 {
tagstr := filteredComments[len(filteredComments)-1].List[0].Text
tagstr = strings.TrimPrefix(tagstr, "//")
tl := strings.Split(strings.TrimSpace(tagstr), " ")
for _, ts := range tl {
tl := strings.SplitSeq(strings.TrimSpace(tagstr), " ")
for ts := range tl {
tf := strings.Split(ts, ":")
if len(tf) != 2 {
continue
Expand Down Expand Up @@ -347,7 +365,7 @@ func (s *{{$name}}Stub) {{.Num}}({{.NamedParams}}) ({{.Results}}) {
return os.WriteFile(outfile, formatted, 0o666)
}

func doTemplate(w io.Writer, info interface{}, templ string) error {
func doTemplate(w io.Writer, info any, templ string) error {
t := template.Must(template.New("").
Funcs(template.FuncMap{}).Parse(templ))

Expand Down
2 changes: 1 addition & 1 deletion apt/make_debs.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func part2(base, product, extra string) {

OrPanic(sh.Command("cp", "-r", "apt/DEBIAN", dir).Run())
sess := sh.NewSession()
for _, env := range strings.Split(extra, " ") {
for env := range strings.SplitSeq(extra, " ") {
if len(env) == 0 {
continue
}
Expand Down
13 changes: 2 additions & 11 deletions build/openrpc/curio.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"openrpc": "1.2.6",
"openrpc": "1.3.2",
"info": {
"title": "Curio RPC API",
"version": "1.27.3-rc2"
Expand Down Expand Up @@ -376,17 +376,8 @@
],
"items": [
{
"items": [
{
"title": "number",
"description": "Number is a number",
"type": [
"number"
]
}
],
"type": [
"array"
"string"
]
}
],
Expand Down
6 changes: 3 additions & 3 deletions cmd/curio/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,11 +294,11 @@ var indexSampleCmd = &cli.Command{
CID string `json:"cid"`
}

mhMap := make([]map[string]interface{}, 0, len(samples))
mhMap := make([]map[string]any, 0, len(samples))
jsonMap := make(map[string]mhJson, len(samples))
for _, sample := range samples {
cidv1 := cid.NewCidV1(cid.DagProtobuf, sample)
m := map[string]interface{}{
m := map[string]any{
MhHex: sample.HexString(),
MhB58: sample.B58String(),
CID: cidv1.String(),
Expand Down Expand Up @@ -329,7 +329,7 @@ var indexSampleCmd = &cli.Command{
},
}

func PrintJson(obj interface{}) error {
func PrintJson(obj any) error {
resJson, err := json.MarshalIndent(obj, "", " ")
if err != nil {
return xerrors.Errorf("marshalling json: %w", err)
Expand Down
2 changes: 1 addition & 1 deletion cmd/curio/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ func TestConfig(t *testing.T) {
func TestCustomConfigDurationJson(t *testing.T) {
ref := new(jsonschema.Reflector)
ref.Mapper = func(i reflect.Type) *jsonschema.Schema {
if i == reflect.TypeOf(time.Second) {
if i == reflect.TypeFor[time.Duration]() {
return &jsonschema.Schema{
Type: "string",
Format: "duration",
Expand Down
15 changes: 5 additions & 10 deletions cmd/curio/guidedsetup/guidedsetup.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"os/signal"
"path"
"path/filepath"
"slices"
"strings"
"syscall"

Expand Down Expand Up @@ -108,7 +109,7 @@ var GuidedsetupCmd = &cli.Command{
},
}

func setupCtrlC(say func(style lipgloss.Style, key message.Reference, a ...interface{})) {
func setupCtrlC(say func(style lipgloss.Style, key message.Reference, a ...any)) {
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
go func() {
Expand Down Expand Up @@ -205,8 +206,8 @@ var nonSPSteps = []nonSPStep{
}

type MigrationData struct {
T func(key message.Reference, a ...interface{}) string
say func(style lipgloss.Style, key message.Reference, a ...interface{})
T func(key message.Reference, a ...any) string
say func(style lipgloss.Style, key message.Reference, a ...any)
selectTemplates *promptui.SelectTemplates
MinerConfigPath string
DB *harmonydb.DB
Expand Down Expand Up @@ -851,13 +852,7 @@ func optionalStorageStep(d *MigrationData) {
}

// Check if path already exists
exists := false
for _, p := range localPaths {
if p == expandedPath {
exists = true
break
}
}
exists := slices.Contains(localPaths, expandedPath)
if exists {
d.say(notice, "Path already exists")
continue
Expand Down
Loading
Loading