Skip to content

Commit f29deb8

Browse files
Unique-DivineOleg Nikonychevonikonychev
authored
feat: update deps and code for Nibiru v2 (v2.6.0) (#67)
* feat: uniswap v3 data source * cosmetics * linter * fix: liner * linter, refactor * feat: fallback to public ethereum nodes * chore: docs * chore: removed old test * feat: cap USDa price to 1.01 * doc: readme * refactor: linter * feat(justfile): add just commands * chore: changelog, linter, fmt * feat: update deps and code for Nibiru v2 (v2.6.0) * chore: changelog * fix: linter, align Go versions in CI, and fix Makefile * test: update tests for new geth version + linter * ci: incremenet go version in golangci-lint.yml * refactor: upgrade to golangic-lint v2 * ci: incremenet go version in golangci-lint.yml --------- Co-authored-by: Oleg Nikonychev <onikonychev@Olegs-MacBook-Pro.local> Co-authored-by: Oleg Nikonychev <oleg.nikonychev@gmail.com>
1 parent 532ad6a commit f29deb8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1833
-589
lines changed

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ METRICS_PORT="8080"
2222
ETHEREUM_RPC_ENDPOINT="https://mainnet.infura.io/v3/<INFURA_API_KEY>"
2323

2424
# Optional, used if custom exclusive ETHEREUM_RPC_ENDPOINT not set, defaults to public endpoints (see in the code)
25-
ETHEREUM_RPC_PUBLIC_ENDPOINTS="https://eth.llamarpc.com,https://cloudflare-eth.com/,https://rpc.flashbots.net/"
25+
ETHEREUM_RPC_PUBLIC_ENDPOINTS="https://eth.llamarpc.com,https://cloudflare-eth.com/,https://rpc.flashbots.net/"

.github/workflows/golangcli-lint.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525

2626
- uses: actions/setup-go@v5
2727
with:
28-
go-version: 1.21
28+
go-version: 1.24
2929
cache: false # the golangci-lint action already caches for us (https://github.com/golangci/golangci-lint-action#performance)
3030

3131
# Use GitHub actions output paramters to get go paths. For more info, see
@@ -49,10 +49,10 @@ jobs:
4949
key: go-mod-cache-${{ hashFiles('**/go.sum') }}
5050

5151
- name: golangci-lint
52-
uses: golangci/golangci-lint-action@v6
52+
uses: golangci/golangci-lint-action@v8
5353
with:
5454
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
55-
version: v1.54.2
55+
version: v2.1
5656

5757
# Optional: working directory, useful for monorepos
5858
# working-directory: somedir

.github/workflows/tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- name: Set up Go
1717
uses: actions/setup-go@v3
1818
with:
19-
go-version: 1.19
19+
go-version: 1.24
2020
cache: true
2121

2222
- name: Run all tests.
@@ -30,7 +30,7 @@ jobs:
3030
- name: Set up Go
3131
uses: actions/setup-go@v3
3232
with:
33-
go-version: 1.19
33+
go-version: 1.24
3434
cache: true
3535

3636
- name: Run all tests.

.golangci.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
version: "2"
2+
linters:
3+
enable:
4+
- importas
5+
- whitespace
6+
settings:
7+
importas:
8+
alias:
9+
- pkg: github.com/pkg/errors
10+
alias: pkgerrors
11+
- pkg: cosmossdk.io/errors
12+
alias: sdkioerrors
13+
- pkg: github.com/cosmos/cosmos-sdk/types/errors
14+
alias: sdkerrors
15+
- pkg: cosmossdk.io/math
16+
alias: sdkmath
17+
- pkg: github.com/cosmos/cosmos-sdk/types
18+
alias: sdk
19+
- pkg: github.com/cometbft/cometbft/rpc/core
20+
alias: cmtrpccoretypes
21+
- pkg: github.com/cometbft/cometbft/rpc/client
22+
alias: cmtrpcclient
23+
- pkg: github.com/cometbft/cometbft/config
24+
alias: cmtcfg
25+
- pkg: github.com/cometbft/cometbft/libs/cli
26+
alias: cmtcli
27+
- pkg: github.com/cometbft/cometbft/libs/rand
28+
alias: cmtrand
29+
- pkg: github.com/cometbft/cometbft/types
30+
alias: cmttypes
31+
no-unaliased: true
32+
no-extra-aliases: false
33+
misspell:
34+
locale: US
35+
revive:
36+
rules:
37+
- name: exported
38+
disabled: true
39+
exclusions:
40+
generated: lax
41+
presets:
42+
- comments
43+
- common-false-positives
44+
- legacy
45+
- std-error-handling
46+
rules:
47+
- path: (.+)\.go$
48+
text: github.com\/stretchr\/testify\/suite\.Suite contains sync\.RWMutex
49+
paths:
50+
- third_party$
51+
- builtin$
52+
- examples$
53+
issues:
54+
max-issues-per-linter: 0
55+
max-same-issues: 0
56+
fix: true
57+
severity:
58+
default: error
59+
formatters:
60+
enable:
61+
- goimports
62+
settings:
63+
goimports:
64+
local-prefixes:
65+
- github.com/NibiruChain/pricefeeder
66+
exclusions:
67+
generated: lax
68+
paths:
69+
- third_party$
70+
- builtin$
71+
- examples$
72+

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3939

4040
## [Unreleased]
4141

42+
- [#67](https://github.com/NibiruChain/pricefeeder/pull/67) - feat: update deps and code for Nibiru v2 (v2.6.0)
4243
- [#63](https://github.com/NibiruChain/pricefeeder/pull/63) - chore: add changelog
4344
- [#64](https://github.com/NibiruChain/pricefeeder/pull/64) - feat: Uniswap V3 data source for USDa from Avalon.
4445

Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
PACKAGE_NAME := github.com/NibiruChain/pricefeeder
2-
GOLANG_CROSS_VERSION ?= v1.19.4
32
VERSION ?= $(shell git describe --tags --abbrev=0)
43
COMMIT ?= $(shell git rev-parse HEAD)
54
BUILD_TARGETS := build install
@@ -28,4 +27,4 @@ run-debug:
2827

2928
.PHONY: build install
3029
$(BUILD_TARGETS):
31-
CGO_ENABLED=0 go $@ -mod=readonly -ldflags="-s -w -X github.com/NibiruChain/pricefeeder/cmd.Version=$(VERSION) -X github.com/NibiruChain/pricefeeder/cmd.CommitHash=$(COMMIT)" .
30+
CGO_ENABLED=1 go $@ -mod=readonly -ldflags="-s -w -X github.com/NibiruChain/pricefeeder/cmd.Version=$(VERSION) -X github.com/NibiruChain/pricefeeder/cmd.CommitHash=$(COMMIT)" .

cmd/root.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@ import (
77
"os"
88
"os/signal"
99

10-
"github.com/NibiruChain/nibiru/app"
10+
"github.com/NibiruChain/nibiru/v2/gosdk"
11+
"github.com/prometheus/client_golang/prometheus/promhttp"
12+
"github.com/rs/zerolog"
13+
"github.com/spf13/cobra"
14+
1115
"github.com/NibiruChain/pricefeeder/config"
1216
"github.com/NibiruChain/pricefeeder/feeder"
1317
"github.com/NibiruChain/pricefeeder/feeder/eventstream"
1418
"github.com/NibiruChain/pricefeeder/feeder/priceposter"
1519
"github.com/NibiruChain/pricefeeder/feeder/priceprovider"
16-
"github.com/prometheus/client_golang/prometheus/promhttp"
17-
"github.com/rs/zerolog"
18-
"github.com/spf13/cobra"
1920
)
2021

2122
func setupLogger() zerolog.Logger {
@@ -49,7 +50,7 @@ var rootCmd = &cobra.Command{
4950
Short: "Pricefeeder daemon for posting prices to Nibiru Chain",
5051
Run: func(cmd *cobra.Command, args []string) {
5152
logger := setupLogger()
52-
app.SetPrefixes(app.AccountAddressPrefix)
53+
gosdk.EnsureNibiruPrefix()
5354

5455
c := config.MustGet()
5556

config/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"fmt"
77
"os"
88

9-
"github.com/NibiruChain/nibiru/x/common/asset"
9+
"github.com/NibiruChain/nibiru/v2/x/common/asset"
1010
sdk "github.com/cosmos/cosmos-sdk/types"
1111
"github.com/joho/godotenv"
1212

config/config_test.go

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,45 @@ import (
44
"os"
55
"testing"
66

7-
"github.com/NibiruChain/nibiru/app"
7+
"github.com/NibiruChain/nibiru/v2/gosdk"
88
"github.com/stretchr/testify/require"
99
)
1010

1111
func init() {
12-
app.SetPrefixes(app.AccountAddressPrefix)
12+
gosdk.EnsureNibiruPrefix()
1313
}
1414

1515
func TestConfig_Get(t *testing.T) {
16-
os.Setenv("CHAIN_ID", "nibiru-localnet-0")
17-
os.Setenv("GRPC_ENDPOINT", "localhost:9090")
18-
os.Setenv("WEBSOCKET_ENDPOINT", "ws://localhost:26657/websocket")
19-
os.Setenv("FEEDER_MNEMONIC", "earth wash broom grow recall fitness")
20-
os.Setenv(
21-
"EXCHANGE_SYMBOLS_MAP",
22-
"{\"bitfinex\": {\"ubtc:unusd\": \"tBTCUSD\", \"ueth:unusd\": \"tETHUSD\", \"uusd:unusd\": \"tUSTUSD\"}}",
23-
)
24-
os.Setenv("VALIDATOR_ADDRESS", "nibivaloper1d7zygazerfwx4l362tnpcp0ramzm97xvv9ryxr")
25-
os.Setenv("ETHEREUM_RPC_ENDPOINT", "https://mainnet.infura.io/v3/DUMMY_INFURA_KEY")
16+
for _, err := range []error{
17+
os.Setenv("CHAIN_ID", "nibiru-localnet-0"),
18+
os.Setenv("GRPC_ENDPOINT", "localhost:9090"),
19+
os.Setenv("WEBSOCKET_ENDPOINT", "ws://localhost:26657/websocket"),
20+
os.Setenv("FEEDER_MNEMONIC", "earth wash broom grow recall fitness"),
21+
os.Setenv(
22+
"EXCHANGE_SYMBOLS_MAP",
23+
"{\"bitfinex\": {\"ubtc:unusd\": \"tBTCUSD\", \"ueth:unusd\": \"tETHUSD\", \"uusd:unusd\": \"tUSTUSD\"}}",
24+
),
25+
os.Setenv("VALIDATOR_ADDRESS", "nibivaloper1d7zygazerfwx4l362tnpcp0ramzm97xvv9ryxr"),
26+
os.Setenv("ETHEREUM_RPC_ENDPOINT", "https://mainnet.infura.io/v3/DUMMY_INFURA_KEY"),
27+
} {
28+
require.NoError(t, err)
29+
}
2630
_, err := Get()
2731
require.NoError(t, err)
2832
}
2933

3034
func TestConfig_Without_EXCHANGE_SYMBOLS_MAP(t *testing.T) {
31-
os.Unsetenv("EXCHANGE_SYMBOLS_MAP")
32-
os.Setenv("CHAIN_ID", "nibiru-localnet-0")
33-
os.Setenv("GRPC_ENDPOINT", "localhost:9090")
34-
os.Setenv("WEBSOCKET_ENDPOINT", "ws://localhost:26657/websocket")
35-
os.Setenv("FEEDER_MNEMONIC", "earth wash broom grow recall fitness")
36-
os.Setenv("VALIDATOR_ADDRESS", "nibivaloper1d7zygazerfwx4l362tnpcp0ramzm97xvv9ryxr")
37-
os.Setenv("ETHEREUM_RPC_ENDPOINT", "https://mainnet.infura.io/v3/DUMMY_INFURA_KEY")
35+
for _, err := range []error{
36+
os.Unsetenv("EXCHANGE_SYMBOLS_MAP"),
37+
os.Setenv("CHAIN_ID", "nibiru-localnet-0"),
38+
os.Setenv("GRPC_ENDPOINT", "localhost:9090"),
39+
os.Setenv("WEBSOCKET_ENDPOINT", "ws://localhost:26657/websocket"),
40+
os.Setenv("FEEDER_MNEMONIC", "earth wash broom grow recall fitness"),
41+
os.Setenv("VALIDATOR_ADDRESS", "nibivaloper1d7zygazerfwx4l362tnpcp0ramzm97xvv9ryxr"),
42+
os.Setenv("ETHEREUM_RPC_ENDPOINT", "https://mainnet.infura.io/v3/DUMMY_INFURA_KEY"),
43+
} {
44+
require.NoError(t, err)
45+
}
3846
_, err := Get()
3947
require.NoError(t, err)
4048
}

feeder/eventstream/stream.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ import (
77
"sync/atomic"
88
"time"
99

10-
oracletypes "github.com/NibiruChain/nibiru/x/oracle/types"
11-
"github.com/NibiruChain/pricefeeder/types"
10+
oracletypes "github.com/NibiruChain/nibiru/v2/x/oracle/types"
1211
"github.com/rs/zerolog"
1312
"google.golang.org/grpc"
1413
"google.golang.org/grpc/credentials"
1514
"google.golang.org/grpc/credentials/insecure"
15+
16+
"github.com/NibiruChain/pricefeeder/types"
1617
)
1718

1819
var _ types.EventStream = (*Stream)(nil)
@@ -46,9 +47,6 @@ func Dial(tendermintRPCEndpoint string, grpcEndpoint string, enableTLS bool, log
4647
panic(err)
4748
}
4849

49-
if err != nil {
50-
panic(err)
51-
}
5250
oracleClient := oracletypes.NewQueryClient(conn)
5351

5452
const newBlockSubscribe = `{"jsonrpc":"2.0","method":"subscribe","id":0,"params":{"query":"tm.event='NewBlock'"}}`

0 commit comments

Comments
 (0)