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

Deps: upgrade golang verion to 1.23 and upgrade golanglint-ci #272

Merged
merged 1 commit into from
Aug 27, 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
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.22.5'
go-version: '1.23'
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.57.2
version: v1.60.3
args: --timeout=5m
test:
name: Test
Expand All @@ -29,7 +29,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 1.22.x
go-version: 1.23.x

- name: Golang tests
env:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This is an indexing layer for Celestia DA written in Golang that operates on top

- Git
- [Docker](https://docs.docker.com/engine/install/)
- [Go 1.22.5](https://go.dev/doc/install) (for development and testing)
- [Go 1.23](https://go.dev/doc/install) (for development and testing)

### Local run ###

Expand Down
2 changes: 1 addition & 1 deletion build/api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ---------------------------------------------------------------------
# The first stage container, for building the application
# ---------------------------------------------------------------------
FROM golang:1.22.5-alpine as builder
FROM golang:1.23-alpine as builder

ENV CGO_ENABLED=0
ENV GO111MODULE=on
Expand Down
2 changes: 1 addition & 1 deletion build/indexer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ---------------------------------------------------------------------
# The first stage container, for building the application
# ---------------------------------------------------------------------
FROM golang:1.22.5-alpine as builder
FROM golang:1.23-alpine as builder

ENV CGO_ENABLED=0
ENV GO111MODULE=on
Expand Down
2 changes: 1 addition & 1 deletion build/quotes/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ---------------------------------------------------------------------
# The first stage container, for building the application
# ---------------------------------------------------------------------
FROM golang:1.22.5-alpine as builder
FROM golang:1.23-alpine as builder

ENV CGO_ENABLED=0
ENV GO111MODULE=on
Expand Down
4 changes: 2 additions & 2 deletions cmd/api/gas/tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ func (tracker *Tracker) compute(txs []storage.Gas, gasLimit int64, data *info) {
)

for i, p := range percentiles {
threshold := uint64(float64(gasLimit) * p)
for sumGas < int64(threshold) && txIndex < len(txs)-1 {
threshold := int64(float64(gasLimit) * p)
for sumGas < threshold && txIndex < len(txs)-1 {
txIndex++
sumGas += txs[txIndex].GasWanted
}
Expand Down
20 changes: 10 additions & 10 deletions cmd/api/handler/address.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ func (handler *AddressHandler) Transactions(c echo.Context) error {
}

fltrs := storage.TxFilter{
Limit: int(req.Limit),
Offset: int(req.Offset),
Limit: req.Limit,
Offset: req.Offset,
Sort: pgSort(req.Sort),
Status: req.Status,
Height: req.Height,
Expand Down Expand Up @@ -218,8 +218,8 @@ func (handler *AddressHandler) Transactions(c echo.Context) error {

type getAddressMessages struct {
Hash string `param:"hash" validate:"required,address"`
Limit uint64 `query:"limit" validate:"omitempty,min=1,max=100"`
Offset uint64 `query:"offset" validate:"omitempty,min=0"`
Limit int `query:"limit" validate:"omitempty,min=1,max=100"`
Offset int `query:"offset" validate:"omitempty,min=0"`
Sort string `query:"sort" validate:"omitempty,oneof=asc desc"`
MsgType StringArray `query:"msg_type" validate:"omitempty,dive,msg_type"`
}
Expand All @@ -238,8 +238,8 @@ func (p *getAddressMessages) SetDefault() {

func (p *getAddressMessages) ToFilters() storage.AddressMsgsFilter {
return storage.AddressMsgsFilter{
Limit: int(p.Limit),
Offset: int(p.Offset),
Limit: p.Limit,
Offset: p.Offset,
Sort: pgSort(p.Sort),
MessageTypes: p.MsgType,
}
Expand Down Expand Up @@ -295,8 +295,8 @@ func (handler *AddressHandler) Messages(c echo.Context) error {

type getBlobLogsForAddress struct {
Hash string `param:"hash" validate:"required,address"`
Limit uint64 `query:"limit" validate:"omitempty,min=1,max=100"`
Offset uint64 `query:"offset" validate:"omitempty,min=0"`
Limit int `query:"limit" validate:"omitempty,min=1,max=100"`
Offset int `query:"offset" validate:"omitempty,min=0"`
Sort string `query:"sort" validate:"omitempty,oneof=asc desc"`
SortBy string `query:"sort_by" validate:"omitempty,oneof=time size"`
}
Expand Down Expand Up @@ -347,8 +347,8 @@ func (handler *AddressHandler) Blobs(c echo.Context) error {
c.Request().Context(),
addressId,
storage.BlobLogFilters{
Limit: int(req.Limit),
Offset: int(req.Offset),
Limit: req.Limit,
Offset: req.Offset,
Sort: pgSort(req.Sort),
SortBy: req.SortBy,
},
Expand Down
12 changes: 6 additions & 6 deletions cmd/api/handler/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,8 @@ func (handler *BlockHandler) GetMessages(c echo.Context) error {
req.SetDefault()

fltrs := storage.MessageListWithTxFilters{
Limit: int(req.Limit),
Offset: int(req.Offset),
Limit: req.Limit,
Offset: req.Offset,
Height: req.Height,
MessageTypes: req.MsgType,
ExcludedMessageTypes: req.ExcludedMsgType,
Expand All @@ -305,8 +305,8 @@ func (handler *BlockHandler) GetMessages(c echo.Context) error {

type getBlobsForBlock struct {
Height types.Level `param:"height" validate:"min=0"`
Limit uint64 `query:"limit" validate:"omitempty,min=1,max=100"`
Offset uint64 `query:"offset" validate:"omitempty,min=0"`
Limit int `query:"limit" validate:"omitempty,min=1,max=100"`
Offset int `query:"offset" validate:"omitempty,min=0"`
Sort string `query:"sort" validate:"omitempty,oneof=asc desc"`
SortBy string `query:"sort_by" validate:"omitempty,oneof=time size"`
}
Expand Down Expand Up @@ -355,8 +355,8 @@ func (handler *BlockHandler) Blobs(c echo.Context) error {
c.Request().Context(),
req.Height,
storage.BlobLogFilters{
Limit: int(req.Limit),
Offset: int(req.Offset),
Limit: req.Limit,
Offset: req.Offset,
Sort: pgSort(req.Sort),
SortBy: req.SortBy,
// using time filters to take certain partition
Expand Down
1 change: 1 addition & 0 deletions cmd/api/handler/gas.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ func (handler GasHandler) EstimateForPfb(c echo.Context) error {
if err != nil {
return badRequestError(c, err)
}
//nolint:gosec
sizes[i] = uint32(size)
}

Expand Down
8 changes: 4 additions & 4 deletions cmd/api/handler/namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,8 +422,8 @@ func (handler *NamespaceHandler) BlobMetadata(c echo.Context) error {
type getBlobLogsForNamespace struct {
Id string `param:"id" validate:"required,hexadecimal,len=56"`
Version byte `param:"version"`
Limit uint64 `query:"limit" validate:"omitempty,min=1,max=100"`
Offset uint64 `query:"offset" validate:"omitempty,min=0"`
Limit int `query:"limit" validate:"omitempty,min=1,max=100"`
Offset int `query:"offset" validate:"omitempty,min=0"`
Sort string `query:"sort" validate:"omitempty,oneof=asc desc"`
SortBy string `query:"sort_by" validate:"omitempty,oneof=time size"`
Commitment string `query:"commitment" validate:"omitempty,base64url"`
Expand Down Expand Up @@ -495,8 +495,8 @@ func (handler *NamespaceHandler) GetBlobLogs(c echo.Context) error {
}

fltrs := storage.BlobLogFilters{
Limit: int(req.Limit),
Offset: int(req.Offset),
Limit: req.Limit,
Offset: req.Offset,
Sort: pgSort(req.Sort),
SortBy: req.SortBy,
Commitment: cm,
Expand Down
8 changes: 4 additions & 4 deletions cmd/api/handler/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ func bindAndValidate[T any](c echo.Context) (*T, error) {

type addressTxRequest struct {
Hash string `param:"hash" validate:"required,address"`
Limit uint64 `query:"limit" validate:"omitempty,min=1,max=100"`
Offset uint64 `query:"offset" validate:"omitempty,min=0"`
Limit int `query:"limit" validate:"omitempty,min=1,max=100"`
Offset int `query:"offset" validate:"omitempty,min=0"`
Sort string `query:"sort" validate:"omitempty,oneof=asc desc"`
Height *uint64 `query:"height" validate:"omitempty,min=0"`
Status StringArray `query:"status" validate:"omitempty,dive,status"`
Expand All @@ -111,8 +111,8 @@ func (p *addressTxRequest) SetDefault() {

type listMessageByBlockRequest struct {
Height pkgTypes.Level `param:"height" validate:"required,min=1"`
Limit uint64 `query:"limit" validate:"omitempty,min=1,max=100"`
Offset uint64 `query:"offset" validate:"omitempty,min=0"`
Limit int `query:"limit" validate:"omitempty,min=1,max=100"`
Offset int `query:"offset" validate:"omitempty,min=0"`
MsgType StringArray `query:"msg_type" validate:"omitempty,dive,msg_type"`
ExcludedMsgType StringArray `query:"excluded_msg_type" validate:"omitempty,dive,msg_type"`
}
Expand Down
8 changes: 4 additions & 4 deletions cmd/api/handler/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,8 @@ func (sh StatsHandler) NamespaceSeries(c echo.Context) error {

type priceSeriesRequest struct {
Timeframe string `example:"hour" param:"timeframe" swaggertype:"string" validate:"required,oneof=1m 1h 1d"`
From uint64 `example:"1692892095" query:"from" swaggertype:"integer" validate:"omitempty,min=1"`
To uint64 `example:"1692892095" query:"to" swaggertype:"integer" validate:"omitempty,min=1"`
From int64 `example:"1692892095" query:"from" swaggertype:"integer" validate:"omitempty,min=1"`
To int64 `example:"1692892095" query:"to" swaggertype:"integer" validate:"omitempty,min=1"`
}

// PriceSeries godoc
Expand Down Expand Up @@ -362,10 +362,10 @@ func (sh StatsHandler) PriceSeries(c echo.Context) error {
)

if req.From > 0 {
from = time.Unix(int64(req.From), 0).UTC()
from = time.Unix(req.From, 0).UTC()
}
if req.To > 0 {
to = time.Unix(int64(req.To), 0).UTC()
to = time.Unix(req.To, 0).UTC()
}

histogram, err := sh.price.Get(c.Request().Context(), req.Timeframe, from, to, 100)
Expand Down
8 changes: 4 additions & 4 deletions cmd/api/handler/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,8 @@ func (handler *TxHandler) Genesis(c echo.Context) error {

type getBlobsForTx struct {
Hash string `param:"hash" validate:"required,hexadecimal,len=64"`
Limit uint64 `query:"limit" validate:"omitempty,min=1,max=100"`
Offset uint64 `query:"offset" validate:"omitempty,min=0"`
Limit int `query:"limit" validate:"omitempty,min=1,max=100"`
Offset int `query:"offset" validate:"omitempty,min=0"`
Sort string `query:"sort" validate:"omitempty,oneof=asc desc"`
SortBy string `query:"sort_by" validate:"omitempty,oneof=time size"`
}
Expand Down Expand Up @@ -348,8 +348,8 @@ func (handler *TxHandler) Blobs(c echo.Context) error {
c.Request().Context(),
txId,
storage.BlobLogFilters{
Limit: int(req.Limit),
Offset: int(req.Offset),
Limit: req.Limit,
Offset: req.Offset,
Sort: pgSort(req.Sort),
SortBy: req.SortBy,
},
Expand Down
1 change: 1 addition & 0 deletions cmd/api/handler/websocket/channel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ func BenchmarkProcessingMessage(b *testing.B) {
for i := 0; i < b.N; i++ {
height := uint64(i)

//nolint:gosec
err := channel.processMessage(storage.Block{
Id: height,
Height: types.Level(height),
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/celenium-io/celestia-indexer

go 1.22.5
go 1.23

require (
cosmossdk.io/errors v1.0.1
Expand Down Expand Up @@ -31,7 +31,7 @@ require (
github.com/goccy/go-json v0.10.2
github.com/gorilla/websocket v1.5.0
github.com/gosimple/slug v1.13.1
github.com/grafana/pyroscope-go v1.1.1
github.com/grafana/pyroscope-go v1.1.2
github.com/json-iterator/go v1.1.12
github.com/labstack/echo-contrib v0.15.0
github.com/labstack/echo/v4 v4.12.0
Expand Down Expand Up @@ -158,7 +158,7 @@ require (
github.com/gorilla/handlers v1.5.2 // indirect
github.com/gorilla/mux v1.8.1 // indirect
github.com/gosimple/unidecode v1.0.1 // indirect
github.com/grafana/pyroscope-go/godeltaprof v0.1.6 // indirect
github.com/grafana/pyroscope-go/godeltaprof v0.1.8 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.0 // indirect
Expand Down
9 changes: 4 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -682,10 +682,10 @@ github.com/gosimple/unidecode v1.0.1 h1:hZzFTMMqSswvf0LBJZCZgThIZrpDHFXux9KeGmn6
github.com/gosimple/unidecode v1.0.1/go.mod h1:CP0Cr1Y1kogOtx0bJblKzsVWrqYaqfNOnHzpgWw4Awc=
github.com/grafana/otel-profiling-go v0.5.1 h1:stVPKAFZSa7eGiqbYuG25VcqYksR6iWvF3YH66t4qL8=
github.com/grafana/otel-profiling-go v0.5.1/go.mod h1:ftN/t5A/4gQI19/8MoWurBEtC6gFw8Dns1sJZ9W4Tls=
github.com/grafana/pyroscope-go v1.1.1 h1:PQoUU9oWtO3ve/fgIiklYuGilvsm8qaGhlY4Vw6MAcQ=
github.com/grafana/pyroscope-go v1.1.1/go.mod h1:Mw26jU7jsL/KStNSGGuuVYdUq7Qghem5P8aXYXSXG88=
github.com/grafana/pyroscope-go/godeltaprof v0.1.6 h1:nEdZ8louGAplSvIJi1HVp7kWvFvdiiYg3COLlTwJiFo=
github.com/grafana/pyroscope-go/godeltaprof v0.1.6/go.mod h1:Tk376Nbldo4Cha9RgiU7ik8WKFkNpfds98aUzS8omLE=
github.com/grafana/pyroscope-go v1.1.2 h1:7vCfdORYQMCxIzI3NlYAs3FcBP760+gWuYWOyiVyYx8=
github.com/grafana/pyroscope-go v1.1.2/go.mod h1:HSSmHo2KRn6FasBA4vK7BMiQqyQq8KSuBKvrhkXxYPU=
github.com/grafana/pyroscope-go/godeltaprof v0.1.8 h1:iwOtYXeeVSAeYefJNaxDytgjKtUuKQbJqgAIjlnicKg=
github.com/grafana/pyroscope-go/godeltaprof v0.1.8/go.mod h1:2+l7K7twW49Ct4wFluZD3tZ6e0SjanjcUUBPVD/UuGU=
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 h1:+9834+KizmvFV7pXQGSXQTsaWhq2GjuNUt0aUU0YBYw=
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0/go.mod h1:z0ButlSOZa5vEBq9m2m2hlwIgKw+rp3sdCBRoJY+30Y=
github.com/grpc-ecosystem/grpc-gateway v1.8.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
Expand Down Expand Up @@ -786,7 +786,6 @@ github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+o
github.com/klauspost/compress v1.12.3/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg=
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
github.com/klauspost/compress v1.15.11/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM=
github.com/klauspost/compress v1.17.3/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM=
github.com/klauspost/compress v1.17.8 h1:YcnTYrq7MikUT7k0Yb5eceMmALQPYBW/Xltxn0NAMnU=
github.com/klauspost/compress v1.17.8/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM=
Expand Down
1 change: 1 addition & 0 deletions internal/storage/constant.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,6 @@ func (c Constant) MustUint32() uint32 {
if err != nil {
panic(err)
}
//nolint:gosec
return uint32(i)
}
3 changes: 3 additions & 0 deletions internal/storage/postgres/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,11 @@ func (b *Blocks) ByHash(ctx context.Context, hash []byte) (block storage.Block,
func (b *Blocks) ListWithStats(ctx context.Context, limit, offset uint64, order sdk.SortOrder) (blocks []*storage.Block, err error) {
subQuery := b.DB().NewSelect().
Model(&blocks)

//nolint:gosec
subQuery = limitScope(subQuery, int(limit))
if offset > 0 {
//nolint:gosec
subQuery = subQuery.Offset(int(offset))
}
if order == sdk.SortOrderAsc {
Expand Down
3 changes: 3 additions & 0 deletions pkg/indexer/blob_saver/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ func (module *Module) init(ctx context.Context) error {
if err != nil {
return errors.Wrap(err, "can't receive head")
}
//nolint:gosec
module.head = pkgTypes.Level(head)
return nil
}
Expand Down Expand Up @@ -174,10 +175,12 @@ func (module *Module) processEndOfBlock(ctx context.Context, height pkgTypes.Lev
}

func (module *Module) processBlob(msg *Msg) error {
//nolint:gosec
ns, err := namespace.New(uint8(msg.Blob.NamespaceVersion), msg.Blob.NamespaceId)
if err != nil {
return errors.Wrapf(err, "can't parse namespace: version=%d id=%x", msg.Blob.NamespaceVersion, msg.Blob.NamespaceId)
}
//nolint:gosec
b := sqBlob.New(ns, msg.Blob.Data, uint8(msg.Blob.ShareVersion))
commitment, err := inclusion.CreateCommitment(b, merkle.HashFromByteSlices, appconsts.SubtreeRootThreshold(uint64(msg.Blob.ShareVersion)))
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions pkg/indexer/parser/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func processBlob(blobs []*storage.BlobLog, d decode.DecodedTx, t *storage.Tx) {
)
for i := range blobs {
blobs[i].ContentType = http.DetectContentType(d.Blobs[i].Data)
//nolint:gosec
sharesUsed := appshares.SparseSharesNeeded(uint32(blobs[i].Size))
gas := decimal.NewFromInt(int64(sharesUsed)).Mul(gasPerBlobByte)
gasConsumedOnBlobs = gasConsumedOnBlobs.Add(gas)
Expand Down
2 changes: 2 additions & 0 deletions pkg/indexer/rollback/balances.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ func getBalanceUpdates(
if err != nil {
return nil, err
}

//nolint:gosec
address.LastHeight = pkgTypes.Level(lastHeight)
updates[address.Address] = address
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/indexer/storage/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ package storage

import (
"github.com/celenium-io/celestia-indexer/internal/storage"
"github.com/celenium-io/celestia-indexer/pkg/types"
"github.com/shopspring/decimal"
)

func updateState(block *storage.Block, totalAccounts, totalNamespaces int64, totalValidators int, totalVotingPower decimal.Decimal, state *storage.State) {
if types.Level(block.Id) <= state.LastHeight {
if block.Id <= uint64(state.LastHeight) {
return
}

Expand Down
Loading