Skip to content

Commit

Permalink
Merge pull request #894 from crypto-com/fix/missing-msg-create-client
Browse files Browse the repository at this point in the history
Fix: missing msg create client
  • Loading branch information
vincentysc authored Dec 2, 2024
2 parents ecfae3e + c90d674 commit f01e2f2
Show file tree
Hide file tree
Showing 55 changed files with 3,161 additions and 1,204 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ jobs:
steps:
- uses: actions/setup-go@v2
with:
go-version: '1.18'
go-version: '1.23'
- uses: actions/checkout@v2
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: v1.49
version: v1.60.1

# Optional: working directory, useful for monorepos
# working-directory: somedir
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
steps:
- uses: actions/setup-go@v2
with:
go-version: '1.18'
go-version: '1.23'
- name: Env
run: |
go version
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.PHONY: has_docker has_docker_compose lint build_ginkgo_image test test_watch ginkgo

GOLANGCI_LINT_VERSION := "v1.49.0"
GOLANGCI_LINT_VERSION := "v1.60.1"

# Use lazy assignment(`=`) such that command existence are evaluated when used
GO = $(shell command -v go)
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,13 @@ config := bootstrap.Config{
Color: false,
},
CosmosVersionEnabledHeight: bootstrap.CosmosVersionEnabledHeightConfig{
// BLock height from cosmos sdk version v0.42.7
// Block height from cosmos sdk version v0.42.7
V0_42_7: 0,
},
CronosVersionEnabledHeight: bootstrap.CronosVersionEnabledHeightConfig{
// Block height from cronos version v1.4.0-rc3
V1_4_0: 0,
},
GithubAPI: bootstrap.GithubAPIConfig{
// Username of your git hub api account
Username: "username",
Expand Down
5 changes: 3 additions & 2 deletions bootstrap/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/crypto-com/chain-indexing/appinterface/rdb"
config "github.com/crypto-com/chain-indexing/bootstrap/config"
projection_entity "github.com/crypto-com/chain-indexing/entity/projection"
"github.com/crypto-com/chain-indexing/external/ethereumtxinnermsgdecoder"
applogger "github.com/crypto-com/chain-indexing/external/logger"
"github.com/crypto-com/chain-indexing/external/txdecoder"
"github.com/crypto-com/chain-indexing/infrastructure/metric/prometheus"
Expand Down Expand Up @@ -80,9 +81,9 @@ func (a *app) InitHTTPAPIServer(registry RouteRegistry) {
}
}

func (a *app) InitIndexService(projections []projection_entity.Projection, cronJobs []projection_entity.CronJob, txDecoder txdecoder.TxDecoder) {
func (a *app) InitIndexService(projections []projection_entity.Projection, cronJobs []projection_entity.CronJob, txDecoder txdecoder.TxDecoder, ethereumTxInnerMsgDecoder ethereumtxinnermsgdecoder.EthereumTxInnerMsgDecoder) {
if a.config.IndexService.Enable {
a.indexService = NewIndexService(a.logger, a.rdbConn, a.config, projections, cronJobs, txDecoder)
a.indexService = NewIndexService(a.logger, a.rdbConn, a.config, projections, cronJobs, txDecoder, ethereumTxInnerMsgDecoder)
}
}

Expand Down
7 changes: 6 additions & 1 deletion bootstrap/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type IndexService struct {
Projection Projection `yaml:"projection" toml:"projection" xml:"projection" json:"projection"`
CronJob CronJob `yaml:"cron_job" toml:"cron_job" xml:"cron_job" json:"cron_job"`
CosmosVersionEnabledHeight CosmosVersionEnabledHeight `yaml:"cosmos_version_enabled_height" toml:"cosmos_version_enabled_height" xml:"cosmos_version_enabled_height" json:"cosmos_version_enabled_height"`
CronosVersionEnabledHeight CronosVersionEnabledHeight `yaml:"cronos_version_enabled_height" toml:"cronos_version_enabled_height" xml:"cronos_version_enabled_height" json:"cronos_version_enabled_height"`
GithubAPI GithubAPI `yaml:"github_api" toml:"github_api" xml:"github_api" json:"github_api"`
BlockResultEventAttributeDecodeMethod string `yaml:"block_result_event_attribute_decode_method" toml:"block_result_event_attribute_decode_method" xml:"block_result_event_attribute_decode_method" json:"block_result_event_attribute_decode_method"`
}
Expand Down Expand Up @@ -93,7 +94,11 @@ type CronJob struct {
}

type CosmosVersionEnabledHeight struct {
V0_42_7 uint64 `yaml:"v_0_42_7" toml:"v_0_42_7" xml:"v_0_42_7" json:"v_0_42_7,omitempty"`
V0_42_7 uint64 `yaml:"v0_42_7" toml:"v0_42_7" xml:"v0_42_7" json:"v0_42_7,omitempty"`
}

type CronosVersionEnabledHeight struct {
V1_4_0 uint64 `yaml:"v1_4_0" toml:"V1_4_0" xml:"V1_4_0" json:"V1_4_0,omitempty"`
}

type GithubAPI struct {
Expand Down
20 changes: 16 additions & 4 deletions bootstrap/indexservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/crypto-com/chain-indexing/bootstrap/config"
"github.com/crypto-com/chain-indexing/entity/event"
projection_entity "github.com/crypto-com/chain-indexing/entity/projection"
"github.com/crypto-com/chain-indexing/external/ethereumtxinnermsgdecoder"
applogger "github.com/crypto-com/chain-indexing/external/logger"
"github.com/crypto-com/chain-indexing/external/txdecoder"
event_usecase "github.com/crypto-com/chain-indexing/usecase/event"
Expand All @@ -36,11 +37,13 @@ type IndexService struct {
BlockResultEventAttributeDecodeMethod string

cosmosVersionBlockHeight utils.CosmosVersionBlockHeight
cronosVersionBlockHeight utils.CronosVersionBlockHeight

GithubAPIUser string
GithubAPIToken string

txDecoder txdecoder.TxDecoder
txDecoder txdecoder.TxDecoder
ethereumTxInnerMsgDecoder ethereumtxinnermsgdecoder.EthereumTxInnerMsgDecoder
}

// NewIndexService creates a new server instance for polling and indexing
Expand All @@ -51,6 +54,7 @@ func NewIndexService(
projections []projection_entity.Projection,
cronJobs []projection_entity.CronJob,
txDecoder txdecoder.TxDecoder,
ethereumTxInnerMsgDecoder ethereumtxinnermsgdecoder.EthereumTxInnerMsgDecoder,
) *IndexService {
return &IndexService{
logger: logger,
Expand All @@ -73,10 +77,14 @@ func NewIndexService(
cosmosVersionBlockHeight: utils.CosmosVersionBlockHeight{
V0_42_7: utils.ParserBlockHeight(config.IndexService.CosmosVersionEnabledHeight.V0_42_7),
},
cronosVersionBlockHeight: utils.CronosVersionBlockHeight{
V1_4_0: utils.ParserBlockHeight(config.IndexService.CronosVersionEnabledHeight.V1_4_0),
},
GithubAPIUser: config.IndexService.GithubAPI.Username,
GithubAPIToken: config.IndexService.GithubAPI.Token,

txDecoder: txDecoder,
txDecoder: txDecoder,
ethereumTxInnerMsgDecoder: ethereumTxInnerMsgDecoder,
}
}

Expand Down Expand Up @@ -157,13 +165,15 @@ func (service *IndexService) RunEventStoreMode() error {
StartingBlockHeight: service.startingBlockHeight,
BlockResultEventAttributeDecodeMethod: service.BlockResultEventAttributeDecodeMethod,
},
TxDecoder: service.txDecoder,
TxDecoder: service.txDecoder,
EthereumTxInnerMsgDecoder: service.ethereumTxInnerMsgDecoder,
},
utils.NewCosmosParserManager(
utils.CosmosParserManagerParams{
Logger: service.logger,
Config: utils.CosmosParserManagerConfig{
CosmosVersionBlockHeight: service.cosmosVersionBlockHeight,
CronosVersionBlockHeight: service.cronosVersionBlockHeight,
},
},
),
Expand Down Expand Up @@ -197,7 +207,8 @@ func (service *IndexService) RunTendermintDirectMode() error {
StartingBlockHeight: service.startingBlockHeight,
BlockResultEventAttributeDecodeMethod: service.BlockResultEventAttributeDecodeMethod,
},
TxDecoder: service.txDecoder,
TxDecoder: service.txDecoder,
EthereumTxInnerMsgDecoder: service.ethereumTxInnerMsgDecoder,
},
utils.NewCosmosParserManager(
utils.CosmosParserManagerParams{
Expand All @@ -206,6 +217,7 @@ func (service *IndexService) RunTendermintDirectMode() error {
}),
Config: utils.CosmosParserManagerConfig{
CosmosVersionBlockHeight: service.cosmosVersionBlockHeight,
CronosVersionBlockHeight: service.cronosVersionBlockHeight,
},
},
),
Expand Down
15 changes: 10 additions & 5 deletions bootstrap/syncmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
cosmosapp_interface "github.com/crypto-com/chain-indexing/appinterface/cosmosapp"
eventhandler_interface "github.com/crypto-com/chain-indexing/appinterface/eventhandler"
tendermint_interface "github.com/crypto-com/chain-indexing/appinterface/tendermint"
"github.com/crypto-com/chain-indexing/external/ethereumtxinnermsgdecoder"
"github.com/crypto-com/chain-indexing/external/txdecoder"
cosmosapp_infrastructure "github.com/crypto-com/chain-indexing/infrastructure/cosmosapp"
"github.com/crypto-com/chain-indexing/usecase/model"
Expand Down Expand Up @@ -54,15 +55,17 @@ type SyncManager struct {

startingBlockHeight int64

txDecoder txdecoder.TxDecoder
txDecoder txdecoder.TxDecoder
ethereumTxInnerMsgDecoder ethereumtxinnermsgdecoder.EthereumTxInnerMsgDecoder

eventAttributeDecoder tendermint_interface.BlockResultEventAttributeDecoder
}

type SyncManagerParams struct {
Logger applogger.Logger
RDbConn rdb.Conn
TxDecoder txdecoder.TxDecoder
Logger applogger.Logger
RDbConn rdb.Conn
TxDecoder txdecoder.TxDecoder
EthereumTxInnerMsgDecoder ethereumtxinnermsgdecoder.EthereumTxInnerMsgDecoder

Config SyncManagerConfig
}
Expand Down Expand Up @@ -144,7 +147,8 @@ func NewSyncManager(

startingBlockHeight: params.Config.StartingBlockHeight,

txDecoder: params.TxDecoder,
txDecoder: params.TxDecoder,
ethereumTxInnerMsgDecoder: params.EthereumTxInnerMsgDecoder,

eventAttributeDecoder: eventAttributeDecoder,
}
Expand Down Expand Up @@ -294,6 +298,7 @@ func (manager *SyncManager) syncBlockWorker(blockHeight int64) ([]command_entity
})

manager.parserManager.TxDecoder = manager.txDecoder
manager.parserManager.EthereumTxInnerMsgDecoder = manager.ethereumTxInnerMsgDecoder
commands, err := parser.ParseBlockToCommands(
parseBlockToCommandsLogger,
manager.parserManager,
Expand Down
2 changes: 1 addition & 1 deletion docker/ginkgo/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.18
FROM golang:1.23

RUN go install github.com/onsi/ginkgo/[email protected]

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package ethereumtxinnermsgdecoder

type EthereumTxInnerMsgDecoder interface {
DecodeCosmosMsgFromTxInput([]byte, string) (map[string]interface{}, error)
}
79 changes: 43 additions & 36 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
module github.com/crypto-com/chain-indexing

go 1.18
go 1.23

require (
github.com/Masterminds/squirrel v1.5.0
github.com/brianvoe/gofakeit/v5 v5.10.1
github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce
github.com/cenkalti/backoff/v4 v4.1.1
github.com/cenkalti/backoff/v4 v4.1.2
github.com/cosmos/cosmos-sdk v0.46.2
github.com/ethereum/go-ethereum v1.10.19
github.com/ettle/strcase v0.1.1
github.com/fasthttp/router v1.3.3
github.com/gogo/protobuf v1.3.3
github.com/golang-migrate/migrate/v4 v4.15.1
github.com/google/go-querystring v1.0.0
github.com/google/uuid v1.3.0
github.com/jackc/pgconn v1.8.0
github.com/jackc/pgtype v1.6.2
github.com/jackc/pgx/v4 v4.10.1
github.com/google/go-querystring v1.1.0
github.com/google/uuid v1.6.0
github.com/jackc/pgconn v1.14.3
github.com/jackc/pgtype v1.14.0
github.com/jackc/pgx/v4 v4.18.2
github.com/json-iterator/go v1.1.12
github.com/lab259/cors v0.2.0
github.com/luci/go-render v0.0.0-20160219211803-9a04cc21af0f
Expand All @@ -26,44 +26,46 @@ require (
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.12.2
github.com/rs/zerolog v1.27.0
github.com/stretchr/testify v1.8.0
github.com/stretchr/testify v1.9.0
github.com/tendermint/tendermint v0.34.21
github.com/valyala/fasthttp v1.17.0
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4
golang.org/x/sync v0.8.0
gopkg.in/yaml.v2 v2.4.0
)

require (
cosmossdk.io/errors v1.0.0-beta.7 // indirect
cosmossdk.io/math v1.0.0-beta.3 // indirect
filippo.io/edwards25519 v1.0.0-rc.1 // indirect
github.com/99designs/go-keychain v0.0.0-20160105221929-9cf53c87839c // indirect
github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d // indirect
github.com/andybalholm/brotli v1.0.0 // indirect
github.com/andybalholm/brotli v1.0.4 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/btcsuite/btcd v0.22.1 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/confio/ics23/go v0.7.0 // indirect
github.com/cosmos/btcutil v1.0.4 // indirect
github.com/cosmos/cosmos-proto v1.0.0-alpha7 // indirect
github.com/cosmos/go-bip39 v1.0.0 // indirect
github.com/cosmos/gorocksdb v1.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
github.com/dgraph-io/badger/v2 v2.2007.4 // indirect
github.com/dgraph-io/ristretto v0.1.0 // indirect
github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect
github.com/dustin/go-humanize v1.0.0 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-kit/kit v0.12.0 // indirect
github.com/go-kit/log v0.2.1 // indirect
github.com/go-logfmt/logfmt v0.5.1 // indirect
github.com/golang/glog v1.0.0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/gogo/protobuf v1.3.3 // indirect
github.com/golang/glog v1.2.0 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect
github.com/google/btree v1.0.1 // indirect
github.com/google/go-github/v35 v35.2.0 // indirect
github.com/google/gofuzz v1.1.1-0.20200604201612-c04b05f3adfa // indirect
github.com/google/go-github/v39 v39.2.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/gtank/merlin v0.1.1 // indirect
github.com/gtank/ristretto255 v0.1.2 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
Expand All @@ -75,16 +77,18 @@ require (
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
github.com/jackc/pgio v1.0.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgproto3/v2 v2.0.7 // indirect
github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b // indirect
github.com/jackc/puddle v1.1.3 // indirect
github.com/jackc/pgproto3/v2 v2.3.3 // indirect
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
github.com/jackc/puddle v1.3.0 // indirect
github.com/jmhodges/levigo v1.0.0 // indirect
github.com/klauspost/compress v1.15.9 // indirect
github.com/klauspost/compress v1.16.0 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect
github.com/lib/pq v1.10.6 // indirect
github.com/lib/pq v1.10.9 // indirect
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
Expand All @@ -94,11 +98,10 @@ require (
github.com/pelletier/go-toml/v2 v2.0.2 // indirect
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/client_model v0.2.1-0.20210607210712-147c58e9608a // indirect
github.com/prometheus/common v0.34.0 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/rogpeppe/go-internal v1.6.2 // indirect
github.com/sasha-s/go-deadlock v0.2.1-0.20190427202633-1595213edefa // indirect
github.com/savsgio/gotils v0.0.0-20200909101946-939aa3fc74fb // indirect
github.com/spf13/afero v1.8.2 // indirect
Expand All @@ -107,23 +110,25 @@ require (
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.12.0 // indirect
github.com/stretchr/objx v0.4.0 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/subosito/gotenv v1.4.0 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
github.com/tendermint/go-amino v0.16.0 // indirect
github.com/tendermint/tm-db v0.6.7 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
go.etcd.io/bbolt v1.3.6 // indirect
go.uber.org/atomic v1.9.0 // indirect
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect
golang.org/x/net v0.0.0-20220726230323-06994584191e // indirect
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f // indirect
google.golang.org/genproto v0.0.0-20220815135757-37a418bb8959 // indirect
google.golang.org/grpc v1.49.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
golang.org/x/crypto v0.27.0 // indirect
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/oauth2 v0.18.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/text v0.18.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240513163218-0867130af1f8 // indirect
google.golang.org/grpc v1.64.1 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/ini.v1 v1.66.6 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand All @@ -135,3 +140,5 @@ replace github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.2-alp
replace github.com/rs/zerolog => github.com/rs/zerolog v1.23.0

replace github.com/enigmampc/btcutil => github.com/scrtlabs/btcutil v1.0.3-0.20200723161021-e2fb6adb2a25

replace github.com/golang-migrate/migrate/v4 => github.com/golang-migrate/migrate/v4 v4.18.1
Loading

0 comments on commit f01e2f2

Please sign in to comment.