Skip to content

Commit

Permalink
Feature: dusk-10 support
Browse files Browse the repository at this point in the history
  • Loading branch information
aopoltorzhicky committed Aug 28, 2024
1 parent 9db2b8a commit aae750d
Show file tree
Hide file tree
Showing 51 changed files with 1,787 additions and 1,374 deletions.
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.4'
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:
GO111MODULE: on
Expand Down
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ linters:
- tagalign
- zerologlint
- copyloopvar
- gosec
- misspell
- noctx
- prealloc
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.4-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.4-alpine as builder
FROM golang:1.23-alpine as builder

ENV CGO_ENABLED=0
ENV GO111MODULE=on
Expand Down
23 changes: 22 additions & 1 deletion cmd/api/handler/responses/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,37 @@ type Action struct {
Type types.ActionType `example:"sequence" format:"string" json:"type" swaggertype:"string"`
TxHash string `example:"652452A670018D629CC116E510BA88C1CABE061336661B1F3D206D248BD558AF" format:"binary" json:"tx_hash,omitempty" swaggertype:"string"`

Fee *Fee `json:"fee,omitempty"`
Data map[string]any `json:"data"`
}

type Fee struct {
Amount string `example:"1000" format:"string" json:"amount" swaggertype:"string"`
Asset string `example:"nria" format:"string" json:"asset" swaggertype:"string"`
}

func NewFee(fee *storage.Fee) *Fee {
if fee == nil {
return nil
}
return &Fee{
Amount: fee.Amount.String(),
Asset: fee.Asset,
}
}

func NewAction(action storage.Action) Action {
return Action{
result := Action{
Id: action.Id,
Height: action.Height,
Time: action.Time,
Position: action.Position,
Type: action.Type,
Data: action.Data,
Fee: NewFee(action.Fee),
}

return result
}

func NewActionWithTx(action storage.ActionWithTx) Action {
Expand All @@ -42,6 +61,7 @@ func NewActionWithTx(action storage.ActionWithTx) Action {
Position: action.Position,
Type: action.Type,
Data: action.Data,
Fee: NewFee(action.Fee),
}

if action.Tx != nil {
Expand All @@ -65,6 +85,7 @@ func NewAddressAction(action storage.AddressAction) Action {
if action.Action != nil {
result.Data = action.Action.Data
result.Position = action.Action.Position
result.Fee = NewFee(action.Action.Fee)
}

return result
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/astria-indexer

go 1.22.4
go 1.23

require (
buf.build/gen/go/astria/primitives/protocolbuffers/go v1.34.2-20240626163506-691883836b9e.2
Expand All @@ -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.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.11.4
Expand Down Expand Up @@ -85,7 +85,7 @@ require (
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/grafana/pyroscope-go/godeltaprof v0.1.6 // indirect
github.com/grafana/pyroscope-go/godeltaprof v0.1.8 // 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
Expand Down
9 changes: 4 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,10 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY=
github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY=
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/grpc-gateway/v2 v2.20.0 h1:bkypFPDjIYGfCYD5mRBvpqxfYX1YCS1PXdKYWi8FsN0=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0/go.mod h1:P+Lt/0by1T8bfcF3z737NnSbmxQAppXMRziHUxPOC8k=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
Expand Down Expand Up @@ -223,7 +223,6 @@ 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.8 h1:YcnTYrq7MikUT7k0Yb5eceMmALQPYBW/Xltxn0NAMnU=
github.com/klauspost/compress v1.17.8/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
Expand Down
1 change: 1 addition & 0 deletions internal/storage/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ type Action struct {
Addresses []*AddressAction `bun:"-"`
BalanceUpdates []BalanceUpdate `bun:"-"`
RollupAction *RollupAction `bun:"-"`
Fee *Fee `bun:"rel:has-one,join:id=action_id"`
}

// TableName -
Expand Down
37 changes: 37 additions & 0 deletions internal/storage/fee.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// SPDX-FileCopyrightText: 2024 PK Lab AG <[email protected]>
// SPDX-License-Identifier: MIT

package storage

import (
"time"

pkgTypes "github.com/celenium-io/astria-indexer/pkg/types"
"github.com/dipdup-net/indexer-sdk/pkg/storage"
"github.com/shopspring/decimal"
"github.com/uptrace/bun"
)

type IFee interface {
storage.Table[*Fee]
}

type Fee struct {
bun.BaseModel `bun:"table:fee" comment:"Table with fees"`

Id uint64 `bun:"id,pk,notnull,autoincrement" comment:"Unique internal identity"`
Height pkgTypes.Level `bun:"height,notnull" comment:"The number (height) of this block"`
Time time.Time `bun:"time,pk,notnull" comment:"The time of block"`
Asset string `bun:"asset" comment:"Fee asset"`
Amount decimal.Decimal `bun:"amount,type:numeric" comment:"Fee amount"`
ActionId uint64 `bun:"action_id" comment:"Connected action id"`
TxId uint64 `bun:"tx_id" comment:"Connected transaction id"`
PayerId uint64 `bun:"payer_id" comment:"Who paid fee"`

ActionType string `bun:"-"`
Payer *Address `bun:"rel:belongs-to"`
}

func (Fee) TableName() string {
return "fee"
}
3 changes: 3 additions & 0 deletions internal/storage/generic.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ var Models = []any{
&AddressAction{},
&BlockSignature{},
&Bridge{},
&Fee{},
}

//go:generate mockgen -source=$GOFILE -destination=mock/$GOFILE -package=mock -typed
Expand All @@ -54,6 +55,7 @@ type Transaction interface {
SaveRollups(ctx context.Context, rollups ...*Rollup) (int64, error)
SaveTransactions(ctx context.Context, txs ...*Tx) error
SaveValidators(ctx context.Context, validators ...*Validator) error
SaveFees(ctx context.Context, fees ...*Fee) error
RetentionBlockSignatures(ctx context.Context, height types.Level) error

RollbackActions(ctx context.Context, height types.Level) (actions []Action, err error)
Expand All @@ -70,6 +72,7 @@ type Transaction interface {
RollbackRollups(ctx context.Context, height types.Level) ([]Rollup, error)
RollbackTxs(ctx context.Context, height types.Level) (txs []Tx, err error)
RollbackValidators(ctx context.Context, height types.Level) (err error)
RollbackFees(ctx context.Context, height types.Level) (err error)
UpdateAddresses(ctx context.Context, address ...*Address) error
UpdateConstants(ctx context.Context, constants ...*Constant) error
UpdateRollups(ctx context.Context, rollups ...*Rollup) error
Expand Down
Loading

0 comments on commit aae750d

Please sign in to comment.