diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c39cdab..fe40630 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,7 +12,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v4 with: - go-version: '1.21.2' + go-version: '1.22.1' cache: false - name: golangci-lint uses: golangci/golangci-lint-action@v3 @@ -29,7 +29,7 @@ jobs: - name: Install Go uses: actions/setup-go@v4 with: - go-version: 1.21.x + go-version: 1.22.x - uses: actions/cache@v3 with: path: | diff --git a/build/api/Dockerfile b/build/api/Dockerfile index caa32ac..d696f0b 100644 --- a/build/api/Dockerfile +++ b/build/api/Dockerfile @@ -1,7 +1,7 @@ # --------------------------------------------------------------------- # The first stage container, for building the application # --------------------------------------------------------------------- -FROM golang:1.21.2-alpine as builder +FROM golang:1.22.1-alpine as builder ENV CGO_ENABLED=0 ENV GO111MODULE=on diff --git a/build/indexer/Dockerfile b/build/indexer/Dockerfile index 9cfdea2..848f16a 100644 --- a/build/indexer/Dockerfile +++ b/build/indexer/Dockerfile @@ -1,7 +1,7 @@ # --------------------------------------------------------------------- # The first stage container, for building the application # --------------------------------------------------------------------- -FROM golang:1.21.2-alpine as builder +FROM golang:1.22.1-alpine as builder ENV CGO_ENABLED=0 ENV GO111MODULE=on diff --git a/cmd/api/docs/docs.go b/cmd/api/docs/docs.go index 4adcfe9..8c84f4a 100644 --- a/cmd/api/docs/docs.go +++ b/cmd/api/docs/docs.go @@ -2065,11 +2065,6 @@ const docTemplate = `{ "format": "binary", "example": "652452A670018D629CC116E510BA88C1CABE061336661B1F3D206D248BD558AF" }, - "tx_id": { - "type": "integer", - "format": "int64", - "example": 10 - }, "type": { "type": "string", "format": "string", @@ -2376,11 +2371,6 @@ const docTemplate = `{ "format": "binary", "example": "652452A670018D629CC116E510BA88C1CABE061336661B1F3D206D248BD558AF" }, - "tx_id": { - "type": "integer", - "format": "int64", - "example": 10 - }, "type": { "type": "string", "format": "string", diff --git a/cmd/api/docs/swagger.json b/cmd/api/docs/swagger.json index 37d437e..b27328a 100644 --- a/cmd/api/docs/swagger.json +++ b/cmd/api/docs/swagger.json @@ -2055,11 +2055,6 @@ "format": "binary", "example": "652452A670018D629CC116E510BA88C1CABE061336661B1F3D206D248BD558AF" }, - "tx_id": { - "type": "integer", - "format": "int64", - "example": 10 - }, "type": { "type": "string", "format": "string", @@ -2366,11 +2361,6 @@ "format": "binary", "example": "652452A670018D629CC116E510BA88C1CABE061336661B1F3D206D248BD558AF" }, - "tx_id": { - "type": "integer", - "format": "int64", - "example": 10 - }, "type": { "type": "string", "format": "string", diff --git a/cmd/api/docs/swagger.yaml b/cmd/api/docs/swagger.yaml index ac61adc..e4dc553 100644 --- a/cmd/api/docs/swagger.yaml +++ b/cmd/api/docs/swagger.yaml @@ -29,10 +29,6 @@ definitions: example: 652452A670018D629CC116E510BA88C1CABE061336661B1F3D206D248BD558AF format: binary type: string - tx_id: - example: 10 - format: int64 - type: integer type: example: sequence format: string @@ -257,10 +253,6 @@ definitions: example: 652452A670018D629CC116E510BA88C1CABE061336661B1F3D206D248BD558AF format: binary type: string - tx_id: - example: 10 - format: int64 - type: integer type: example: sequence format: string diff --git a/cmd/api/handler/responses/action.go b/cmd/api/handler/responses/action.go index d9d017b..f1d116a 100644 --- a/cmd/api/handler/responses/action.go +++ b/cmd/api/handler/responses/action.go @@ -18,7 +18,6 @@ type Action struct { Time time.Time `example:"2023-07-04T03:10:57+00:00" format:"date-time" json:"time" swaggertype:"string"` Position int64 `example:"1" format:"int64" json:"position" swaggertype:"integer"` Type types.ActionType `example:"sequence" format:"string" json:"type" swaggertype:"string"` - TxId uint64 `example:"10" format:"int64" json:"tx_id" swaggertype:"integer"` TxHash string `example:"652452A670018D629CC116E510BA88C1CABE061336661B1F3D206D248BD558AF" format:"binary" json:"tx_hash,omitempty" swaggertype:"string"` Data map[string]any `json:"data"` @@ -31,7 +30,6 @@ func NewAction(action storage.Action) Action { Time: action.Time, Position: action.Position, Type: action.Type, - TxId: action.TxId, Data: action.Data, } } @@ -43,7 +41,6 @@ func NewActionWithTx(action storage.ActionWithTx) Action { Time: action.Time, Position: action.Position, Type: action.Type, - TxId: action.TxId, Data: action.Data, } @@ -59,7 +56,6 @@ func NewAddressAction(action storage.AddressAction) Action { Id: action.ActionId, Height: action.Height, Time: action.Time, - TxId: action.TxId, Type: action.ActionType, } diff --git a/cmd/api/handler/responses/rollup_action.go b/cmd/api/handler/responses/rollup_action.go index 849d7ff..3d067f8 100644 --- a/cmd/api/handler/responses/rollup_action.go +++ b/cmd/api/handler/responses/rollup_action.go @@ -3,7 +3,11 @@ package responses -import "github.com/celenium-io/astria-indexer/internal/storage" +import ( + "encoding/hex" + + "github.com/celenium-io/astria-indexer/internal/storage" +) type RollupAction struct { Action @@ -16,6 +20,10 @@ func NewRollupAction(action storage.RollupAction) RollupAction { Action: NewAction(*action.Action), } + if action.Tx != nil { + result.TxHash = hex.EncodeToString(action.Tx.Hash) + } + if action.Rollup != nil { r := NewRollup(action.Rollup) result.Rollup = &r diff --git a/cmd/api/handler/tx_test.go b/cmd/api/handler/tx_test.go index 970c354..b950d46 100644 --- a/cmd/api/handler/tx_test.go +++ b/cmd/api/handler/tx_test.go @@ -339,7 +339,6 @@ func (s *TxTestSuite) TestGetActions() { s.Require().EqualValues(100, actions[0].Height) s.Require().EqualValues(1, actions[0].Position) s.Require().Equal(testTime, actions[0].Time) - s.Require().EqualValues(1, actions[0].TxId) s.Require().EqualValues(string(types.ActionTypeSequence), actions[0].Type) } diff --git a/go.mod b/go.mod index 37b000a..2a264e8 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/celenium-io/astria-indexer -go 1.21.2 +go 1.22.1 require ( buf.build/gen/go/astria/astria/protocolbuffers/go v1.32.0-20240102174805-d9fa6929f260.1 @@ -15,7 +15,7 @@ require ( github.com/go-testfixtures/testfixtures/v3 v3.9.0 github.com/goccy/go-json v0.10.2 github.com/gorilla/websocket v1.5.0 - github.com/grafana/pyroscope-go v1.0.4 + github.com/grafana/pyroscope-go v1.1.1 github.com/json-iterator/go v1.1.12 github.com/labstack/echo-contrib v0.15.0 github.com/labstack/echo/v4 v4.11.4 @@ -81,7 +81,7 @@ require ( github.com/golang/protobuf v1.5.3 // indirect github.com/google/go-cmp v0.6.0 // indirect github.com/google/uuid v1.3.1 // indirect - github.com/grafana/pyroscope-go/godeltaprof v0.1.4 // indirect + github.com/grafana/pyroscope-go/godeltaprof v0.1.6 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/jackc/pgpassfile v1.0.0 // indirect github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect diff --git a/go.sum b/go.sum index 2e20148..5016d80 100644 --- a/go.sum +++ b/go.sum @@ -183,10 +183,10 @@ github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/grafana/pyroscope-go v1.0.4 h1:oyQX0BOkL+iARXzHuCdIF5TQ7/sRSel1YFViMHC7Bm0= -github.com/grafana/pyroscope-go v1.0.4/go.mod h1:0d7ftwSMBV/Awm7CCiYmHQEG8Y44Ma3YSjt+nWcWztY= -github.com/grafana/pyroscope-go/godeltaprof v0.1.4 h1:mDsJ3ngul7UfrHibGQpV66PbZ3q1T8glz/tK3bQKKEk= -github.com/grafana/pyroscope-go/godeltaprof v0.1.4/go.mod h1:1HSPtjU8vLG0jE9JrTdzjgFqdJ/VgN7fvxBNq3luJko= +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/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= @@ -221,6 +221,7 @@ github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHm github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= +github.com/klauspost/compress v1.17.3/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM= github.com/klauspost/compress v1.17.4 h1:Ej5ixsIri7BrIjBkRZLTo6ghwrEtHFk7ijlczPW4fZ4= github.com/klauspost/compress v1.17.4/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= diff --git a/internal/storage/postgres/scripts.go b/internal/storage/postgres/scripts.go index 3bf5f51..0ba0232 100644 --- a/internal/storage/postgres/scripts.go +++ b/internal/storage/postgres/scripts.go @@ -43,12 +43,12 @@ func (s Storage) createScripts(ctx context.Context, conn *database.Bun, subFolde if len(query) == 0 { continue } - if _, err := s.Connection().DB().NewRaw(string(query)).Exec(ctx); err != nil { + if _, err := conn.DB().NewRaw(string(query)).Exec(ctx); err != nil { return errors.Wrapf(err, "creating %s '%s'", subFolder, files[i].Name()) } } } else { - if _, err := s.Connection().DB().NewRaw(string(raw)).Exec(ctx); err != nil { + if _, err := conn.DB().NewRaw(string(raw)).Exec(ctx); err != nil { return errors.Wrapf(err, "creating %s '%s'", subFolder, files[i].Name()) } }