Skip to content

Commit

Permalink
Merge pull request #90 from neutron-org/feat/sdk-50
Browse files Browse the repository at this point in the history
feat: upgrade dependencies to be compatible with Neutron V4 #NTRN-275
  • Loading branch information
pr0n00gler authored Jul 1, 2024
2 parents 70bbf58 + ed4cbc7 commit 94bc813
Show file tree
Hide file tree
Showing 23 changed files with 1,219 additions and 851 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Set up Go 1.21
- name: Set up Go 1.22
uses: actions/setup-go@v4
with:
go-version: '~1.21'
go-version: '~1.22'
id: go

- name: Check out code into the Go module directory
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.21-bullseye as builder
FROM golang:1.22-bullseye as builder

ARG LDFLAGS
RUN mkdir /app
Expand Down
12 changes: 7 additions & 5 deletions cmd/neutron_query_relayer/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ package cmd

import (
"context"
relaysubscriber "github.com/neutron-org/neutron-query-relayer/internal/subscriber"
"log"
"os"
"os/signal"
"sync"
"syscall"

neutronapp "github.com/neutron-org/neutron/app"
relaysubscriber "github.com/neutron-org/neutron-query-relayer/internal/subscriber"

neutronappconfig "github.com/neutron-org/neutron/v4/app/config"

"github.com/neutron-org/neutron-query-relayer/internal/relay"

Expand All @@ -21,7 +22,7 @@ import (
nlogger "github.com/neutron-org/neutron-logger"
"github.com/neutron-org/neutron-query-relayer/internal/app"
"github.com/neutron-org/neutron-query-relayer/internal/config"
neutrontypes "github.com/neutron-org/neutron/x/interchainqueries/types"
neutrontypes "github.com/neutron-org/neutron/v4/x/interchainqueries/types"
)

const (
Expand All @@ -43,8 +44,7 @@ func init() {

func startRelayer() {
// set global values for prefixes for cosmos-sdk when parsing addresses and so on
globalCfg := neutronapp.GetDefaultConfig()
globalCfg.Seal()
globalCfg := neutronappconfig.GetDefaultConfig()

logRegistry, err := nlogger.NewRegistry(
mainContext,
Expand Down Expand Up @@ -113,6 +113,8 @@ func startRelayer() {
logger.Fatal("Failed to get NewDefaultTxSubmitChecker", zap.Error(err))
}

globalCfg.Seal()

wg.Add(1)
go func() {
defer wg.Done()
Expand Down
285 changes: 157 additions & 128 deletions go.mod

Large diffs are not rendered by default.

1,696 changes: 1,016 additions & 680 deletions go.sum

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions internal/kvprocessor/kvprocessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import (
"context"
"errors"
"fmt"
"github.com/avast/retry-go/v4"
tmclient "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint"
"time"

"github.com/avast/retry-go/v4"
tmclient "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint"

neutronmetrics "github.com/neutron-org/neutron-query-relayer/internal/metrics"

sdk "github.com/cosmos/cosmos-sdk/types"
Expand All @@ -18,7 +19,7 @@ import (

"github.com/neutron-org/neutron-query-relayer/internal/relay"
"github.com/neutron-org/neutron-query-relayer/internal/tmquerier"
neutrontypes "github.com/neutron-org/neutron/x/interchainqueries/types"
neutrontypes "github.com/neutron-org/neutron/v4/x/interchainqueries/types"
)

// KVProcessor is implementation of relay.KVProcessor that processes event query KV type.
Expand Down
4 changes: 2 additions & 2 deletions internal/relay/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import (
"go.uber.org/zap"

"github.com/neutron-org/neutron-query-relayer/internal/config"
neutronapp "github.com/neutron-org/neutron/app"
neutronappconfig "github.com/neutron-org/neutron/v4/app/config"
)

func GetNeutronChain(logger *zap.Logger, cfg *config.NeutronChainConfig, chainID string) (*relayer.Chain, error) {
provCfg := cosmos.CosmosProviderConfig{
Key: cfg.SignKeyName,
ChainID: chainID,
RPCAddr: cfg.RPCAddr,
AccountPrefix: neutronapp.Bech32MainPrefix,
AccountPrefix: neutronappconfig.Bech32MainPrefix,
KeyringBackend: cfg.KeyringBackend,
GasAdjustment: cfg.GasAdjustment,
GasPrices: cfg.GasPrices,
Expand Down
2 changes: 1 addition & 1 deletion internal/relay/relayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"github.com/cosmos/relayer/v2/relayer"

"github.com/neutron-org/neutron-query-relayer/internal/config"
neutrontypes "github.com/neutron-org/neutron/x/interchainqueries/types"
neutrontypes "github.com/neutron-org/neutron/v4/x/interchainqueries/types"

"go.uber.org/zap"
)
Expand Down
2 changes: 1 addition & 1 deletion internal/relay/submitter.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

sdk "github.com/cosmos/cosmos-sdk/types"

neutrontypes "github.com/neutron-org/neutron/x/interchainqueries/types"
neutrontypes "github.com/neutron-org/neutron/v4/x/interchainqueries/types"
)

// Submitter knows how to submit proof to the chain
Expand Down
4 changes: 2 additions & 2 deletions internal/relay/subscriber.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package relay
import (
"context"

"github.com/neutron-org/neutron/x/interchainqueries/types"
neutrontypes "github.com/neutron-org/neutron/x/interchainqueries/types"
"github.com/neutron-org/neutron/v4/x/interchainqueries/types"
neutrontypes "github.com/neutron-org/neutron/v4/x/interchainqueries/types"
)

// Subscriber is an interface that subscribes to Neutron and provides chain data in real time.
Expand Down
3 changes: 2 additions & 1 deletion internal/relay/trusted_headers.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ package relay

import (
"context"
tmclient "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint"

tmclient "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint"
)

// TrustedHeaderFetcher able to get trusted headers for a given height
Expand Down
2 changes: 1 addition & 1 deletion internal/relay/txprocessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

ctypes "github.com/cometbft/cometbft/rpc/core/types"

neutrontypes "github.com/neutron-org/neutron/x/interchainqueries/types"
neutrontypes "github.com/neutron-org/neutron/v4/x/interchainqueries/types"
)

// Transaction represents single searched tx with height
Expand Down
6 changes: 3 additions & 3 deletions internal/submit/submitter_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

sdk "github.com/cosmos/cosmos-sdk/types"

neutrontypes "github.com/neutron-org/neutron/x/interchainqueries/types"
neutrontypes "github.com/neutron-org/neutron/v4/x/interchainqueries/types"
)

// SubmitterImpl can submit proofs using `sender` as the transaction transport mechanism
Expand Down Expand Up @@ -62,7 +62,7 @@ func (si *SubmitterImpl) buildProofMsg(height, revision, queryId uint64, allowKV

msg := neutrontypes.MsgSubmitQueryResult{QueryId: queryId, Sender: senderAddr, Result: &queryResult, ClientId: si.clientID}

err = msg.ValidateBasic()
err = msg.Validate()
if err != nil {
return nil, fmt.Errorf("invalid proof message for query=%d: %w", queryId, err)
}
Expand All @@ -83,7 +83,7 @@ func (si *SubmitterImpl) buildTxProofMsg(queryId uint64, proof *neutrontypes.Blo
}
msg := neutrontypes.MsgSubmitQueryResult{QueryId: queryId, Sender: senderAddr, Result: &queryResult, ClientId: si.clientID}

err = msg.ValidateBasic()
err = msg.Validate()
if err != nil {
return nil, fmt.Errorf("invalid tx proof message: %w", err)
}
Expand Down
6 changes: 3 additions & 3 deletions internal/submit/tx_sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func (txs *TxSender) Send(ctx context.Context, msgs []sdk.Msg) (string, error) {
WithGas(gasNeeded).
WithGasPrices(txs.gasPrices)

bz, err := txs.signAndBuildTxBz(txf, msgs)
bz, err := txs.signAndBuildTxBz(ctx, txf, msgs)
if err != nil {
return "", fmt.Errorf("could not sign and build tx bz: %w", err)
}
Expand Down Expand Up @@ -213,13 +213,13 @@ func (txs *TxSender) queryAccount(ctx context.Context, address string) (*authtyp
return &account, nil
}

func (txs *TxSender) signAndBuildTxBz(txf tx.Factory, msgs []sdk.Msg) ([]byte, error) {
func (txs *TxSender) signAndBuildTxBz(ctx context.Context, txf tx.Factory, msgs []sdk.Msg) ([]byte, error) {
txBuilder, err := txf.BuildUnsignedTx(msgs...)
if err != nil {
return nil, fmt.Errorf("failed to build transaction builder: %w", err)
}

err = tx.Sign(txf, txs.signKeyName, txBuilder, false)
err = tx.Sign(ctx, txf, txs.signKeyName, txBuilder, false)

if err != nil {
return nil, fmt.Errorf("error signing transaction: %w", err)
Expand Down
2 changes: 1 addition & 1 deletion internal/subscriber/attributes.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package subscriber

import (
"github.com/neutron-org/neutron/x/interchainqueries/types"
"github.com/neutron-org/neutron/v4/x/interchainqueries/types"
)

const eventTypePrefix = types.EventTypeNeutronMessage
Expand Down
4 changes: 2 additions & 2 deletions internal/subscriber/querier/client/query/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"fmt"
"strconv"

ibcclienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
neutrontypes "github.com/neutron-org/neutron/x/interchainqueries/types"
ibcclienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
neutrontypes "github.com/neutron-org/neutron/v4/x/interchainqueries/types"
)

func (o *NeutronInterchainQueriesRegisteredQueriesOKBodyRegisteredQueriesItems0) ToNeutronRegisteredQuery() (*neutrontypes.RegisteredQuery, error) {
Expand Down
6 changes: 2 additions & 4 deletions internal/subscriber/subscriber.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@ import (
"github.com/neutron-org/neutron-query-relayer/internal/config"
"github.com/neutron-org/neutron-query-relayer/internal/relay"

"github.com/neutron-org/neutron-query-relayer/internal/registry"

instrumenters "github.com/neutron-org/neutron-query-relayer/internal/metrics"

tmtypes "github.com/cometbft/cometbft/rpc/core/types"
"go.uber.org/zap"

rg "github.com/neutron-org/neutron-query-relayer/internal/registry"
neutrontypes "github.com/neutron-org/neutron/x/interchainqueries/types"
neutrontypes "github.com/neutron-org/neutron/v4/x/interchainqueries/types"
)

var (
Expand Down Expand Up @@ -60,7 +58,7 @@ func NewDefaultSubscriber(cfg config.NeutronQueryRelayerConfig, logRegistry *nlo
&Config{
ConnectionID: cfg.NeutronChain.ConnectionID,
WatchedTypes: watchedMsgTypes,
Registry: registry.New(cfg.Registry),
Registry: rg.New(cfg.Registry),
},
rpcClient,
restClient.Query,
Expand Down
2 changes: 1 addition & 1 deletion internal/subscriber/subscriber_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/neutron-org/neutron-query-relayer/internal/subscriber"
"github.com/neutron-org/neutron-query-relayer/internal/subscriber/querier/client/query"
mock_subscriber "github.com/neutron-org/neutron-query-relayer/testutil/mocks/subscriber"
neutrontypes "github.com/neutron-org/neutron/x/interchainqueries/types"
neutrontypes "github.com/neutron-org/neutron/v4/x/interchainqueries/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.uber.org/mock/gomock"
Expand Down
2 changes: 1 addition & 1 deletion internal/subscriber/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (

restclient "github.com/neutron-org/neutron-query-relayer/internal/subscriber/querier/client"
"github.com/neutron-org/neutron-query-relayer/internal/subscriber/querier/client/query"
neutrontypes "github.com/neutron-org/neutron/x/interchainqueries/types"
neutrontypes "github.com/neutron-org/neutron/v4/x/interchainqueries/types"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion internal/tmquerier/querier.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
rpcclienthttp "github.com/cometbft/cometbft/rpc/client/http"
"github.com/cosmos/cosmos-sdk/codec"

neutrontypes "github.com/neutron-org/neutron/x/interchainqueries/types"
neutrontypes "github.com/neutron-org/neutron/v4/x/interchainqueries/types"
)

// Querier can get proofs for stored blockchain values
Expand Down
9 changes: 5 additions & 4 deletions internal/trusted_headers/fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@ package trusted_headers
import (
"context"
"fmt"
"time"

"github.com/avast/retry-go/v4"
ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported"
ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported"
"github.com/cosmos/relayer/v2/relayer/provider"
"time"

"github.com/cosmos/relayer/v2/relayer/chains/cosmos"

neutronmetrics "github.com/neutron-org/neutron-query-relayer/internal/metrics"

"github.com/cosmos/cosmos-sdk/types/query"
clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
tmclient "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint"
clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
tmclient "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint"
"github.com/cosmos/relayer/v2/relayer"
"go.uber.org/zap"
)
Expand Down
4 changes: 2 additions & 2 deletions internal/txprocessor/txprocessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import (
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"go.uber.org/zap"

clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"

"github.com/neutron-org/neutron-query-relayer/internal/relay"
neutrontypes "github.com/neutron-org/neutron/x/interchainqueries/types"
neutrontypes "github.com/neutron-org/neutron/v4/x/interchainqueries/types"
)

type TXProcessor struct {
Expand Down
4 changes: 2 additions & 2 deletions internal/txquerier/txquerier.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/cometbft/cometbft/types"

"github.com/neutron-org/neutron-query-relayer/internal/relay"
neutrontypes "github.com/neutron-org/neutron/x/interchainqueries/types"
neutrontypes "github.com/neutron-org/neutron/v4/x/interchainqueries/types"
)

var TxsChanSize = 100
Expand Down Expand Up @@ -83,7 +83,7 @@ func (t *TXQuerierSrv) SearchTransactions(ctx context.Context, query string) (<-
}

// proofDelivery returns (deliveryProof, deliveryResult, error) for transaction in block 'blockHeight' with index 'txIndexInBlock'
func (t *TXQuerierSrv) proofDelivery(ctx context.Context, blockHeight int64, txIndexInBlock uint32) (*crypto.Proof, *abci.ResponseDeliverTx, error) {
func (t *TXQuerierSrv) proofDelivery(ctx context.Context, blockHeight int64, txIndexInBlock uint32) (*crypto.Proof, *abci.ExecTxResult, error) {
results, err := t.chainClient.BlockResults(ctx, &blockHeight)

if err != nil {
Expand Down

0 comments on commit 94bc813

Please sign in to comment.