Skip to content

Commit 722b44e

Browse files
authored
Update for cosmos-sdk v0.46.1 compatibility (#536)
* deps: update to cosmos-sdk v0.46.1 * refactor: replace AppCons, ClientCreator with Client * ci: use go 1.19 in CI * fix: address review comments
1 parent 2eb987e commit 722b44e

10 files changed

Lines changed: 62 additions & 1059 deletions

File tree

docker/mockserv.Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
FROM --platform=$BUILDPLATFORM golang:1.17-alpine AS build-env
1+
FROM --platform=$BUILDPLATFORM golang:1.19-alpine AS build-env
22

33
# Set working directory for the build
44
WORKDIR /src
55

66
COPY . .
77

8-
RUN go mod tidy -compat=1.17 && \
8+
RUN go mod tidy -compat=1.19 && \
99
go build /src/da/grpc/mockserv/cmd/main.go
1010

1111
# Final image

go.mod

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/celestiaorg/optimint
22

3-
go 1.17
3+
go 1.18
44

55
require (
66
github.com/celestiaorg/go-cnc v0.1.0
@@ -21,7 +21,7 @@ require (
2121
github.com/spf13/cobra v1.5.0
2222
github.com/spf13/viper v1.13.0
2323
github.com/stretchr/testify v1.8.0
24-
github.com/tendermint/tendermint v0.34.20
24+
github.com/tendermint/tendermint v0.34.21
2525
go.uber.org/multierr v1.8.0
2626
golang.org/x/net v0.0.0-20220826154423-83b083e8dc8b
2727
google.golang.org/grpc v1.48.0
@@ -82,6 +82,7 @@ require (
8282
github.com/jbenet/go-temp-err-catcher v0.1.0 // indirect
8383
github.com/jbenet/goprocess v0.1.4 // indirect
8484
github.com/jmhodges/levigo v1.0.0 // indirect
85+
github.com/jtolds/gls v4.20.0+incompatible // indirect
8586
github.com/klauspost/compress v1.15.9 // indirect
8687
github.com/klauspost/cpuid/v2 v2.1.1 // indirect
8788
github.com/koron/go-ssdp v0.0.3 // indirect
@@ -107,7 +108,7 @@ require (
107108
github.com/marten-seemann/tcp v0.0.0-20210406111302-dfbc87cc63fd // indirect
108109
github.com/mattn/go-isatty v0.0.16 // indirect
109110
github.com/mattn/go-pointer v0.0.1 // indirect
110-
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
111+
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
111112
github.com/miekg/dns v1.1.50 // indirect
112113
github.com/mikioh/tcpinfo v0.0.0-20190314235526-30a79bb1804b // indirect
113114
github.com/mikioh/tcpopt v0.0.0-20190314235656-172688c1accc // indirect
@@ -164,7 +165,7 @@ require (
164165
golang.org/x/sys v0.0.0-20220829200755-d48e67d00261 // indirect
165166
golang.org/x/text v0.3.7 // indirect
166167
golang.org/x/tools v0.1.12 // indirect
167-
google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd // indirect
168+
google.golang.org/genproto v0.0.0-20220725144611-272f38e5d71b // indirect
168169
gopkg.in/ini.v1 v1.67.0 // indirect
169170
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
170171
gopkg.in/yaml.v2 v2.4.0 // indirect

go.sum

Lines changed: 9 additions & 995 deletions
Large diffs are not rendered by default.

node/integration_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,23 @@ import (
1010
"testing"
1111
"time"
1212

13-
mockda "github.com/celestiaorg/optimint/da/mock"
14-
"github.com/celestiaorg/optimint/p2p"
15-
"github.com/celestiaorg/optimint/store"
1613
"github.com/stretchr/testify/assert"
1714

1815
"github.com/libp2p/go-libp2p/core/crypto"
1916
"github.com/libp2p/go-libp2p/core/peer"
2017
"github.com/stretchr/testify/mock"
2118
"github.com/stretchr/testify/require"
19+
abcicli "github.com/tendermint/tendermint/abci/client"
2220
abci "github.com/tendermint/tendermint/abci/types"
2321
"github.com/tendermint/tendermint/libs/log"
24-
"github.com/tendermint/tendermint/proxy"
2522
"github.com/tendermint/tendermint/types"
2623

2724
"github.com/celestiaorg/optimint/config"
2825
"github.com/celestiaorg/optimint/da"
26+
mockda "github.com/celestiaorg/optimint/da/mock"
2927
"github.com/celestiaorg/optimint/mocks"
28+
"github.com/celestiaorg/optimint/p2p"
29+
"github.com/celestiaorg/optimint/store"
3030
)
3131

3232
func TestAggregatorMode(t *testing.T) {
@@ -49,7 +49,7 @@ func TestAggregatorMode(t *testing.T) {
4949
BlockTime: 1 * time.Second,
5050
NamespaceID: [8]byte{1, 2, 3, 4, 5, 6, 7, 8},
5151
}
52-
node, err := NewNode(context.Background(), config.NodeConfig{DALayer: "mock", Aggregator: true, BlockManagerConfig: blockManagerConfig}, key, signingKey, proxy.NewLocalClientCreator(app), &types.GenesisDoc{ChainID: "test"}, log.TestingLogger())
52+
node, err := NewNode(context.Background(), config.NodeConfig{DALayer: "mock", Aggregator: true, BlockManagerConfig: blockManagerConfig}, key, signingKey, abcicli.NewLocalClient(nil, app), &types.GenesisDoc{ChainID: "test"}, log.TestingLogger())
5353
require.NoError(err)
5454
require.NotNil(node)
5555

@@ -244,7 +244,7 @@ func createNode(ctx context.Context, n int, aggregator bool, dalc da.DataAvailab
244244
},
245245
keys[n],
246246
signingKey,
247-
proxy.NewLocalClientCreator(app),
247+
abcicli.NewLocalClient(nil, app),
248248
&types.GenesisDoc{ChainID: "test"},
249249
log.TestingLogger().With("node", n))
250250
require.NoError(err)

node/node.go

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ import (
1010
"github.com/libp2p/go-libp2p/core/crypto"
1111
"go.uber.org/multierr"
1212

13+
abciclient "github.com/tendermint/tendermint/abci/client"
1314
abci "github.com/tendermint/tendermint/abci/types"
1415
llcfg "github.com/tendermint/tendermint/config"
1516
"github.com/tendermint/tendermint/libs/log"
1617
"github.com/tendermint/tendermint/libs/service"
1718
corep2p "github.com/tendermint/tendermint/p2p"
18-
"github.com/tendermint/tendermint/proxy"
1919
tmtypes "github.com/tendermint/tendermint/types"
2020

2121
"github.com/celestiaorg/optimint/block"
@@ -50,8 +50,8 @@ const (
5050
// It connects all the components and orchestrates their work.
5151
type Node struct {
5252
service.BaseService
53-
eventBus *tmtypes.EventBus
54-
proxyApp proxy.AppConns
53+
eventBus *tmtypes.EventBus
54+
appClient abciclient.Client
5555

5656
genesis *tmtypes.GenesisDoc
5757
// cache of chunked genesis data.
@@ -79,13 +79,15 @@ type Node struct {
7979
}
8080

8181
// NewNode creates new Optimint node.
82-
func NewNode(ctx context.Context, conf config.NodeConfig, p2pKey crypto.PrivKey, signingKey crypto.PrivKey, clientCreator proxy.ClientCreator, genesis *tmtypes.GenesisDoc, logger log.Logger) (*Node, error) {
83-
proxyApp := proxy.NewAppConns(clientCreator)
84-
proxyApp.SetLogger(logger.With("module", "proxy"))
85-
if err := proxyApp.Start(); err != nil {
86-
return nil, fmt.Errorf("error starting proxy app connections: %w", err)
87-
}
88-
82+
func NewNode(
83+
ctx context.Context,
84+
conf config.NodeConfig,
85+
p2pKey crypto.PrivKey,
86+
signingKey crypto.PrivKey,
87+
appClient abciclient.Client,
88+
genesis *tmtypes.GenesisDoc,
89+
logger log.Logger,
90+
) (*Node, error) {
8991
eventBus := tmtypes.NewEventBus()
9092
eventBus.SetLogger(logger.With("module", "events"))
9193
if err := eventBus.Start(); err != nil {
@@ -124,16 +126,16 @@ func NewNode(ctx context.Context, conf config.NodeConfig, p2pKey crypto.PrivKey,
124126
return nil, err
125127
}
126128

127-
mp := mempoolv1.NewTxMempool(logger, llcfg.DefaultMempoolConfig(), proxyApp.Mempool(), 0)
129+
mp := mempoolv1.NewTxMempool(logger, llcfg.DefaultMempoolConfig(), appClient, 0)
128130
mpIDs := newMempoolIDs()
129131

130-
blockManager, err := block.NewManager(signingKey, conf.BlockManagerConfig, genesis, s, mp, proxyApp.Consensus(), dalc, eventBus, logger.With("module", "BlockManager"))
132+
blockManager, err := block.NewManager(signingKey, conf.BlockManagerConfig, genesis, s, mp, appClient, dalc, eventBus, logger.With("module", "BlockManager"))
131133
if err != nil {
132134
return nil, fmt.Errorf("BlockManager initialization error: %w", err)
133135
}
134136

135137
node := &Node{
136-
proxyApp: proxyApp,
138+
appClient: appClient,
137139
eventBus: eventBus,
138140
genesis: genesis,
139141
conf: conf,
@@ -269,9 +271,9 @@ func (n *Node) EventBus() *tmtypes.EventBus {
269271
return n.eventBus
270272
}
271273

272-
// ProxyApp returns ABCI proxy connections to communicate with application.
273-
func (n *Node) ProxyApp() proxy.AppConns {
274-
return n.proxyApp
274+
// AppClient returns ABCI proxy connections to communicate with application.
275+
func (n *Node) AppClient() abciclient.Client {
276+
return n.appClient
275277
}
276278

277279
// newTxValidator creates a pubsub validator that uses the node's mempool to check the

node/node_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@ import (
66
"testing"
77
"time"
88

9-
"github.com/celestiaorg/optimint/mempool"
109
"github.com/stretchr/testify/assert"
1110
"github.com/stretchr/testify/mock"
1211
"github.com/stretchr/testify/require"
1312

1413
"github.com/libp2p/go-libp2p/core/crypto"
1514
"github.com/libp2p/go-libp2p/core/peer"
15+
abcicli "github.com/tendermint/tendermint/abci/client"
1616
abci "github.com/tendermint/tendermint/abci/types"
1717
"github.com/tendermint/tendermint/libs/log"
18-
"github.com/tendermint/tendermint/proxy"
1918
"github.com/tendermint/tendermint/types"
2019

2120
"github.com/celestiaorg/optimint/config"
21+
"github.com/celestiaorg/optimint/mempool"
2222
"github.com/celestiaorg/optimint/mocks"
2323
)
2424

@@ -31,7 +31,7 @@ func TestStartup(t *testing.T) {
3131
app.On("InitChain", mock.Anything).Return(abci.ResponseInitChain{})
3232
key, _, _ := crypto.GenerateEd25519Key(rand.Reader)
3333
signingKey, _, _ := crypto.GenerateEd25519Key(rand.Reader)
34-
node, err := NewNode(context.Background(), config.NodeConfig{DALayer: "mock"}, key, signingKey, proxy.NewLocalClientCreator(app), &types.GenesisDoc{ChainID: "test"}, log.TestingLogger())
34+
node, err := NewNode(context.Background(), config.NodeConfig{DALayer: "mock"}, key, signingKey, abcicli.NewLocalClient(nil, app), &types.GenesisDoc{ChainID: "test"}, log.TestingLogger())
3535
require.NoError(err)
3636
require.NotNil(node)
3737

@@ -57,7 +57,7 @@ func TestMempoolDirectly(t *testing.T) {
5757
signingKey, _, _ := crypto.GenerateEd25519Key(rand.Reader)
5858
anotherKey, _, _ := crypto.GenerateEd25519Key(rand.Reader)
5959

60-
node, err := NewNode(context.Background(), config.NodeConfig{DALayer: "mock"}, key, signingKey, proxy.NewLocalClientCreator(app), &types.GenesisDoc{ChainID: "test"}, log.TestingLogger())
60+
node, err := NewNode(context.Background(), config.NodeConfig{DALayer: "mock"}, key, signingKey, abcicli.NewLocalClient(nil, app), &types.GenesisDoc{ChainID: "test"}, log.TestingLogger())
6161
require.NoError(err)
6262
require.NotNil(node)
6363

rpc/client/client.go

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"sort"
88
"time"
99

10+
abcicli "github.com/tendermint/tendermint/abci/client"
1011
abci "github.com/tendermint/tendermint/abci/types"
1112
"github.com/tendermint/tendermint/config"
1213
tmbytes "github.com/tendermint/tendermint/libs/bytes"
@@ -60,7 +61,7 @@ func NewClient(node *node.Node) *Client {
6061

6162
// ABCIInfo returns basic information about application state.
6263
func (c *Client) ABCIInfo(ctx context.Context) (*ctypes.ResultABCIInfo, error) {
63-
resInfo, err := c.query().InfoSync(proxy.RequestInfo)
64+
resInfo, err := c.appClient().InfoSync(proxy.RequestInfo)
6465
if err != nil {
6566
return nil, err
6667
}
@@ -74,7 +75,7 @@ func (c *Client) ABCIQuery(ctx context.Context, path string, data tmbytes.HexByt
7475

7576
// ABCIQueryWithOptions queries for data from application.
7677
func (c *Client) ABCIQueryWithOptions(ctx context.Context, path string, data tmbytes.HexBytes, opts rpcclient.ABCIQueryOptions) (*ctypes.ResultABCIQuery, error) {
77-
resQuery, err := c.query().QuerySync(abci.RequestQuery{
78+
resQuery, err := c.appClient().QuerySync(abci.RequestQuery{
7879
Path: path,
7980
Data: data,
8081
Height: opts.Height,
@@ -755,7 +756,7 @@ func (c *Client) UnconfirmedTxs(ctx context.Context, limitPtr *int) (*ctypes.Res
755756
//
756757
// If valid, the tx is automatically added to the mempool.
757758
func (c *Client) CheckTx(ctx context.Context, tx types.Tx) (*ctypes.ResultCheckTx, error) {
758-
res, err := c.mempool().CheckTxSync(abci.RequestCheckTx{Tx: tx})
759+
res, err := c.appClient().CheckTxSync(abci.RequestCheckTx{Tx: tx})
759760
if err != nil {
760761
return nil, err
761762
}
@@ -810,20 +811,8 @@ func (c *Client) resubscribe(subscriber string, q tmpubsub.Query) types.Subscrip
810811
}
811812
}
812813

813-
func (c *Client) consensus() proxy.AppConnConsensus {
814-
return c.node.ProxyApp().Consensus()
815-
}
816-
817-
func (c *Client) mempool() proxy.AppConnMempool {
818-
return c.node.ProxyApp().Mempool()
819-
}
820-
821-
func (c *Client) query() proxy.AppConnQuery {
822-
return c.node.ProxyApp().Query()
823-
}
824-
825-
func (c *Client) snapshot() proxy.AppConnSnapshot {
826-
return c.node.ProxyApp().Snapshot()
814+
func (c *Client) appClient() abcicli.Client {
815+
return c.node.AppClient()
827816
}
828817

829818
func (c *Client) normalizeHeight(height *int64) uint64 {

rpc/client/client_test.go

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ import (
1515

1616
"github.com/libp2p/go-libp2p/core/crypto"
1717
"github.com/libp2p/go-libp2p/core/peer"
18+
abcicli "github.com/tendermint/tendermint/abci/client"
1819
abci "github.com/tendermint/tendermint/abci/types"
1920
tmcrypto "github.com/tendermint/tendermint/crypto"
2021
"github.com/tendermint/tendermint/crypto/ed25519"
2122
"github.com/tendermint/tendermint/crypto/encoding"
2223
"github.com/tendermint/tendermint/libs/bytes"
2324
"github.com/tendermint/tendermint/libs/log"
2425
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
25-
"github.com/tendermint/tendermint/proxy"
2626
tmtypes "github.com/tendermint/tendermint/types"
2727

2828
"github.com/celestiaorg/optimint/config"
@@ -40,14 +40,11 @@ var expectedInfo = abci.ResponseInfo{
4040

4141
var mockTxProcessingTime = 10 * time.Millisecond
4242

43-
func TestConnectionGetters(t *testing.T) {
43+
func TestConnectionGetter(t *testing.T) {
4444
assert := assert.New(t)
4545

4646
_, rpc := getRPC(t)
47-
assert.NotNil(rpc.consensus())
48-
assert.NotNil(rpc.mempool())
49-
assert.NotNil(rpc.snapshot())
50-
assert.NotNil(rpc.query())
47+
assert.NotNil(rpc.appClient())
5148
}
5249

5350
func TestInfo(t *testing.T) {
@@ -91,7 +88,7 @@ func TestGenesisChunked(t *testing.T) {
9188
mockApp.On("InitChain", mock.Anything).Return(abci.ResponseInitChain{})
9289
privKey, _, _ := crypto.GenerateEd25519Key(cryptorand.Reader)
9390
signingKey, _, _ := crypto.GenerateEd25519Key(cryptorand.Reader)
94-
n, _ := node.NewNode(context.Background(), config.NodeConfig{DALayer: "mock"}, privKey, signingKey, proxy.NewLocalClientCreator(mockApp), genDoc, log.TestingLogger())
91+
n, _ := node.NewNode(context.Background(), config.NodeConfig{DALayer: "mock"}, privKey, signingKey, abcicli.NewLocalClient(nil, mockApp), genDoc, log.TestingLogger())
9592

9693
rpc := NewClient(n)
9794

@@ -410,7 +407,7 @@ func TestTx(t *testing.T) {
410407
BlockManagerConfig: config.BlockManagerConfig{
411408
BlockTime: 200 * time.Millisecond,
412409
}},
413-
key, signingKey, proxy.NewLocalClientCreator(mockApp),
410+
key, signingKey, abcicli.NewLocalClient(nil, mockApp),
414411
&tmtypes.GenesisDoc{ChainID: "test"},
415412
log.TestingLogger())
416413
require.NoError(err)
@@ -657,7 +654,7 @@ func TestValidatorSetHandling(t *testing.T) {
657654
waitCh <- nil
658655
})
659656

660-
node, err := node.NewNode(context.Background(), config.NodeConfig{DALayer: "mock", Aggregator: true, BlockManagerConfig: config.BlockManagerConfig{BlockTime: 10 * time.Millisecond}}, key, signingKey, proxy.NewLocalClientCreator(app), &tmtypes.GenesisDoc{ChainID: "test", Validators: genesisValidators}, log.TestingLogger())
657+
node, err := node.NewNode(context.Background(), config.NodeConfig{DALayer: "mock", Aggregator: true, BlockManagerConfig: config.BlockManagerConfig{BlockTime: 10 * time.Millisecond}}, key, signingKey, abcicli.NewLocalClient(nil, app), &tmtypes.GenesisDoc{ChainID: "test", Validators: genesisValidators}, log.TestingLogger())
661658
require.NoError(err)
662659
require.NotNil(node)
663660

@@ -777,7 +774,7 @@ func getRPC(t *testing.T) (*mocks.Application, *Client) {
777774
app.On("InitChain", mock.Anything).Return(abci.ResponseInitChain{})
778775
key, _, _ := crypto.GenerateEd25519Key(crand.Reader)
779776
signingKey, _, _ := crypto.GenerateEd25519Key(crand.Reader)
780-
node, err := node.NewNode(context.Background(), config.NodeConfig{DALayer: "mock"}, key, signingKey, proxy.NewLocalClientCreator(app), &tmtypes.GenesisDoc{ChainID: "test"}, log.TestingLogger())
777+
node, err := node.NewNode(context.Background(), config.NodeConfig{DALayer: "mock"}, key, signingKey, abcicli.NewLocalClient(nil, app), &tmtypes.GenesisDoc{ChainID: "test"}, log.TestingLogger())
781778
require.NoError(err)
782779
require.NotNil(node)
783780

@@ -847,7 +844,7 @@ func TestMempool2Nodes(t *testing.T) {
847844
P2P: config.P2PConfig{
848845
ListenAddress: "/ip4/127.0.0.1/tcp/9001",
849846
},
850-
}, key1, signingKey1, proxy.NewLocalClientCreator(app), &tmtypes.GenesisDoc{ChainID: "test"}, log.TestingLogger())
847+
}, key1, signingKey1, abcicli.NewLocalClient(nil, app), &tmtypes.GenesisDoc{ChainID: "test"}, log.TestingLogger())
851848
require.NoError(err)
852849
require.NotNil(node1)
853850

@@ -857,7 +854,7 @@ func TestMempool2Nodes(t *testing.T) {
857854
ListenAddress: "/ip4/127.0.0.1/tcp/9002",
858855
Seeds: "/ip4/127.0.0.1/tcp/9001/p2p/" + id1.Pretty(),
859856
},
860-
}, key2, signingKey2, proxy.NewLocalClientCreator(app), &tmtypes.GenesisDoc{ChainID: "test"}, log.TestingLogger())
857+
}, key2, signingKey2, abcicli.NewLocalClient(nil, app), &tmtypes.GenesisDoc{ChainID: "test"}, log.TestingLogger())
861858
require.NoError(err)
862859
require.NotNil(node1)
863860

rpc/json/service_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ import (
1919

2020
"github.com/gorilla/rpc/v2/json2"
2121
"github.com/libp2p/go-libp2p/core/crypto"
22+
abciclient "github.com/tendermint/tendermint/abci/client"
2223
abci "github.com/tendermint/tendermint/abci/types"
2324
"github.com/tendermint/tendermint/libs/log"
24-
"github.com/tendermint/tendermint/proxy"
2525
"github.com/tendermint/tendermint/types"
2626

2727
"github.com/celestiaorg/optimint/config"
@@ -290,7 +290,7 @@ func getRPC(t *testing.T) (*mocks.Application, *client.Client) {
290290
})
291291
key, _, _ := crypto.GenerateEd25519Key(rand.Reader)
292292
signingKey, _, _ := crypto.GenerateEd25519Key(rand.Reader)
293-
node, err := node.NewNode(context.Background(), config.NodeConfig{Aggregator: true, DALayer: "mock", BlockManagerConfig: config.BlockManagerConfig{BlockTime: 1 * time.Second}}, key, signingKey, proxy.NewLocalClientCreator(app), &types.GenesisDoc{ChainID: "test"}, log.TestingLogger())
293+
node, err := node.NewNode(context.Background(), config.NodeConfig{Aggregator: true, DALayer: "mock", BlockManagerConfig: config.BlockManagerConfig{BlockTime: 1 * time.Second}}, key, signingKey, abciclient.NewLocalClient(nil, app), &types.GenesisDoc{ChainID: "test"}, log.TestingLogger())
294294
require.NoError(err)
295295
require.NotNil(node)
296296

state/executor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ func (e *BlockExecutor) ApplyBlock(ctx context.Context, state types.State, block
127127
return types.State{}, nil, err
128128
}
129129

130-
// This makes calls to the ProxyApp
130+
// This makes calls to the AppClient
131131
resp, err := e.execute(ctx, state, block)
132132
if err != nil {
133133
return types.State{}, nil, err

0 commit comments

Comments
 (0)